Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'net-6.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Pull networking fixes from Paolo Abeni:
"Current release - regressions:

- tcp: fix tcp_disordered_ack() vs usec TS resolution

Current release - new code bugs:

- dpll: sanitize possible null pointer dereference in
dpll_pin_parent_pin_set()

- eth: octeon_ep: initialise control mbox tasks before using APIs

Previous releases - regressions:

- io_uring/af_unix: disable sending io_uring over sockets

- eth: mlx5e:
- TC, don't offload post action rule if not supported
- fix possible deadlock on mlx5e_tx_timeout_work

- eth: iavf: fix iavf_shutdown to call iavf_remove instead iavf_close

- eth: bnxt_en: fix skb recycling logic in bnxt_deliver_skb()

- eth: ena: fix DMA syncing in XDP path when SWIOTLB is on

- eth: team: fix use-after-free when an option instance allocation
fails

Previous releases - always broken:

- neighbour: don't let neigh_forced_gc() disable preemption for long

- net: prevent mss overflow in skb_segment()

- ipv6: support reporting otherwise unknown prefix flags in
RTM_NEWPREFIX

- tcp: remove acked SYN flag from packet in the transmit queue
correctly

- eth: octeontx2-af:
- fix a use-after-free in rvu_nix_register_reporters
- fix promisc mcam entry action

- eth: dwmac-loongson: make sure MDIO is initialized before use

- eth: atlantic: fix double free in ring reinit logic"

* tag 'net-6.7-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (62 commits)
net: atlantic: fix double free in ring reinit logic
appletalk: Fix Use-After-Free in atalk_ioctl
net: stmmac: Handle disabled MDIO busses from devicetree
net: stmmac: dwmac-qcom-ethqos: Fix drops in 10M SGMII RX
dpaa2-switch: do not ask for MDB, VLAN and FDB replay
dpaa2-switch: fix size of the dma_unmap
net: prevent mss overflow in skb_segment()
vsock/virtio: Fix unsigned integer wrap around in virtio_transport_has_space()
Revert "tcp: disable tcp_autocorking for socket when TCP_NODELAY flag is set"
MIPS: dts: loongson: drop incorrect dwmac fallback compatible
stmmac: dwmac-loongson: drop useless check for compatible fallback
stmmac: dwmac-loongson: Make sure MDIO is initialized before use
tcp: disable tcp_autocorking for socket when TCP_NODELAY flag is set
dpll: sanitize possible null pointer dereference in dpll_pin_parent_pin_set()
net: ena: Fix XDP redirection error
net: ena: Fix DMA syncing in XDP path when SWIOTLB is on
net: ena: Fix xdp drops handling due to multibuf packets
net: ena: Destroy correct number of xdp queues upon failure
net: Remove acked SYN flag from packet in the transmit queue correctly
qed: Fix a potential use-after-free in qed_cxt_tables_alloc
...

+1154 -586
-1
MAINTAINERS
··· 19564 19564 F: drivers/misc/sgi-xp/ 19565 19565 19566 19566 SHARED MEMORY COMMUNICATIONS (SMC) SOCKETS 19567 - M: Karsten Graul <kgraul@linux.ibm.com> 19568 19567 M: Wenjia Zhang <wenjia@linux.ibm.com> 19569 19568 M: Jan Karcher <jaka@linux.ibm.com> 19570 19569 R: D. Wythe <alibuda@linux.alibaba.com>
+1 -2
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi
··· 130 130 compatible = "pci0014,7a03.0", 131 131 "pci0014,7a03", 132 132 "pciclass0c0320", 133 - "pciclass0c03", 134 - "loongson, pci-gmac"; 133 + "pciclass0c03"; 135 134 136 135 reg = <0x1800 0x0 0x0 0x0 0x0>; 137 136 interrupts = <12 IRQ_TYPE_LEVEL_LOW>,
+1 -2
arch/mips/boot/dts/loongson/ls7a-pch.dtsi
··· 193 193 compatible = "pci0014,7a03.0", 194 194 "pci0014,7a03", 195 195 "pciclass020000", 196 - "pciclass0200", 197 - "loongson, pci-gmac"; 196 + "pciclass0200"; 198 197 199 198 reg = <0x1800 0x0 0x0 0x0 0x0>; 200 199 interrupts = <12 IRQ_TYPE_LEVEL_HIGH>,
+4 -4
drivers/atm/solos-pci.c
··· 449 449 struct sk_buff *skb; 450 450 unsigned int len; 451 451 452 - spin_lock(&card->cli_queue_lock); 452 + spin_lock_bh(&card->cli_queue_lock); 453 453 skb = skb_dequeue(&card->cli_queue[SOLOS_CHAN(atmdev)]); 454 - spin_unlock(&card->cli_queue_lock); 454 + spin_unlock_bh(&card->cli_queue_lock); 455 455 if(skb == NULL) 456 456 return sprintf(buf, "No data.\n"); 457 457 ··· 956 956 struct pkt_hdr *header; 957 957 958 958 /* Remove any yet-to-be-transmitted packets from the pending queue */ 959 - spin_lock(&card->tx_queue_lock); 959 + spin_lock_bh(&card->tx_queue_lock); 960 960 skb_queue_walk_safe(&card->tx_queue[port], skb, tmpskb) { 961 961 if (SKB_CB(skb)->vcc == vcc) { 962 962 skb_unlink(skb, &card->tx_queue[port]); 963 963 solos_pop(vcc, skb); 964 964 } 965 965 } 966 - spin_unlock(&card->tx_queue_lock); 966 + spin_unlock_bh(&card->tx_queue_lock); 967 967 968 968 skb = alloc_skb(sizeof(*header), GFP_KERNEL); 969 969 if (!skb) {
+8 -5
drivers/dpll/dpll_netlink.c
··· 925 925 struct netlink_ext_ack *extack) 926 926 { 927 927 struct nlattr *tb[DPLL_A_PIN_MAX + 1]; 928 - enum dpll_pin_state state; 929 928 u32 ppin_idx; 930 929 int ret; 931 930 ··· 935 936 return -EINVAL; 936 937 } 937 938 ppin_idx = nla_get_u32(tb[DPLL_A_PIN_PARENT_ID]); 938 - state = nla_get_u32(tb[DPLL_A_PIN_STATE]); 939 - ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack); 940 - if (ret) 941 - return ret; 939 + 940 + if (tb[DPLL_A_PIN_STATE]) { 941 + enum dpll_pin_state state = nla_get_u32(tb[DPLL_A_PIN_STATE]); 942 + 943 + ret = dpll_pin_on_pin_state_set(pin, ppin_idx, state, extack); 944 + if (ret) 945 + return ret; 946 + } 942 947 943 948 return 0; 944 949 }
-3
drivers/net/ethernet/amazon/ena/ena_eth_com.c
··· 328 328 * compare it to the stored version, just create the meta 329 329 */ 330 330 if (io_sq->disable_meta_caching) { 331 - if (unlikely(!ena_tx_ctx->meta_valid)) 332 - return -EINVAL; 333 - 334 331 *have_meta = true; 335 332 return ena_com_create_meta(io_sq, ena_meta); 336 333 }
+26 -27
drivers/net/ethernet/amazon/ena/ena_netdev.c
··· 74 74 struct ena_tx_buffer *tx_info); 75 75 static int ena_create_io_tx_queues_in_range(struct ena_adapter *adapter, 76 76 int first_index, int count); 77 + static void ena_free_all_io_tx_resources_in_range(struct ena_adapter *adapter, 78 + int first_index, int count); 77 79 78 80 /* Increase a stat by cnt while holding syncp seqlock on 32bit machines */ 79 81 static void ena_increase_stat(u64 *statp, u64 cnt, ··· 459 457 460 458 static int ena_setup_and_create_all_xdp_queues(struct ena_adapter *adapter) 461 459 { 460 + u32 xdp_first_ring = adapter->xdp_first_ring; 461 + u32 xdp_num_queues = adapter->xdp_num_queues; 462 462 int rc = 0; 463 463 464 - rc = ena_setup_tx_resources_in_range(adapter, adapter->xdp_first_ring, 465 - adapter->xdp_num_queues); 464 + rc = ena_setup_tx_resources_in_range(adapter, xdp_first_ring, xdp_num_queues); 466 465 if (rc) 467 466 goto setup_err; 468 467 469 - rc = ena_create_io_tx_queues_in_range(adapter, 470 - adapter->xdp_first_ring, 471 - adapter->xdp_num_queues); 468 + rc = ena_create_io_tx_queues_in_range(adapter, xdp_first_ring, xdp_num_queues); 472 469 if (rc) 473 470 goto create_err; 474 471 475 472 return 0; 476 473 477 474 create_err: 478 - ena_free_all_io_tx_resources(adapter); 475 + ena_free_all_io_tx_resources_in_range(adapter, xdp_first_ring, xdp_num_queues); 479 476 setup_err: 480 477 return rc; 481 478 } ··· 1493 1492 if (unlikely(!skb)) 1494 1493 return NULL; 1495 1494 1496 - /* sync this buffer for CPU use */ 1497 - dma_sync_single_for_cpu(rx_ring->dev, 1498 - dma_unmap_addr(&rx_info->ena_buf, paddr) + pkt_offset, 1499 - len, 1500 - DMA_FROM_DEVICE); 1501 1495 skb_copy_to_linear_data(skb, buf_addr + buf_offset, len); 1502 1496 dma_sync_single_for_device(rx_ring->dev, 1503 1497 dma_unmap_addr(&rx_info->ena_buf, paddr) + pkt_offset, ··· 1511 1515 1512 1516 buf_len = SKB_DATA_ALIGN(len + buf_offset + tailroom); 1513 1517 1514 - pre_reuse_paddr = dma_unmap_addr(&rx_info->ena_buf, paddr); 1515 - 1516 1518 /* If XDP isn't loaded try to reuse part of the RX buffer */ 1517 1519 reuse_rx_buf_page = !is_xdp_loaded && 1518 1520 ena_try_rx_buf_page_reuse(rx_info, buf_len, len, pkt_offset); 1519 - 1520 - dma_sync_single_for_cpu(rx_ring->dev, 1521 - pre_reuse_paddr + pkt_offset, 1522 - len, 1523 - DMA_FROM_DEVICE); 1524 1521 1525 1522 if (!reuse_rx_buf_page) 1526 1523 ena_unmap_rx_buff_attrs(rx_ring, rx_info, DMA_ATTR_SKIP_CPU_SYNC); ··· 1660 1671 } 1661 1672 } 1662 1673 1663 - static int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp) 1674 + static int ena_xdp_handle_buff(struct ena_ring *rx_ring, struct xdp_buff *xdp, u16 num_descs) 1664 1675 { 1665 1676 struct ena_rx_buffer *rx_info; 1666 1677 int ret; 1678 + 1679 + /* XDP multi-buffer packets not supported */ 1680 + if (unlikely(num_descs > 1)) { 1681 + netdev_err_once(rx_ring->adapter->netdev, 1682 + "xdp: dropped unsupported multi-buffer packets\n"); 1683 + ena_increase_stat(&rx_ring->rx_stats.xdp_drop, 1, &rx_ring->syncp); 1684 + return ENA_XDP_DROP; 1685 + } 1667 1686 1668 1687 rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id]; 1669 1688 xdp_prepare_buff(xdp, page_address(rx_info->page), 1670 1689 rx_info->buf_offset, 1671 1690 rx_ring->ena_bufs[0].len, false); 1672 - /* If for some reason we received a bigger packet than 1673 - * we expect, then we simply drop it 1674 - */ 1675 - if (unlikely(rx_ring->ena_bufs[0].len > ENA_XDP_MAX_MTU)) 1676 - return ENA_XDP_DROP; 1677 1691 1678 1692 ret = ena_xdp_execute(rx_ring, xdp); 1679 1693 ··· 1711 1719 int xdp_flags = 0; 1712 1720 int total_len = 0; 1713 1721 int xdp_verdict; 1722 + u8 pkt_offset; 1714 1723 int rc = 0; 1715 1724 int i; 1716 1725 ··· 1738 1745 1739 1746 /* First descriptor might have an offset set by the device */ 1740 1747 rx_info = &rx_ring->rx_buffer_info[rx_ring->ena_bufs[0].req_id]; 1741 - rx_info->buf_offset += ena_rx_ctx.pkt_offset; 1748 + pkt_offset = ena_rx_ctx.pkt_offset; 1749 + rx_info->buf_offset += pkt_offset; 1742 1750 1743 1751 netif_dbg(rx_ring->adapter, rx_status, rx_ring->netdev, 1744 1752 "rx_poll: q %d got packet from ena. descs #: %d l3 proto %d l4 proto %d hash: %x\n", 1745 1753 rx_ring->qid, ena_rx_ctx.descs, ena_rx_ctx.l3_proto, 1746 1754 ena_rx_ctx.l4_proto, ena_rx_ctx.hash); 1747 1755 1756 + dma_sync_single_for_cpu(rx_ring->dev, 1757 + dma_unmap_addr(&rx_info->ena_buf, paddr) + pkt_offset, 1758 + rx_ring->ena_bufs[0].len, 1759 + DMA_FROM_DEVICE); 1760 + 1748 1761 if (ena_xdp_present_ring(rx_ring)) 1749 - xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp); 1762 + xdp_verdict = ena_xdp_handle_buff(rx_ring, &xdp, ena_rx_ctx.descs); 1750 1763 1751 1764 /* allocate skb and fill it */ 1752 1765 if (xdp_verdict == ENA_XDP_PASS) ··· 1776 1777 if (xdp_verdict & ENA_XDP_FORWARDED) { 1777 1778 ena_unmap_rx_buff_attrs(rx_ring, 1778 1779 &rx_ring->rx_buffer_info[req_id], 1779 - 0); 1780 + DMA_ATTR_SKIP_CPU_SYNC); 1780 1781 rx_ring->rx_buffer_info[req_id].page = NULL; 1781 1782 } 1782 1783 }
+4 -1
drivers/net/ethernet/aquantia/atlantic/aq_ring.c
··· 938 938 return; 939 939 940 940 kfree(self->buff_ring); 941 + self->buff_ring = NULL; 941 942 942 - if (self->dx_ring) 943 + if (self->dx_ring) { 943 944 dma_free_coherent(aq_nic_get_dev(self->aq_nic), 944 945 self->size * self->dx_size, self->dx_ring, 945 946 self->dx_ring_pa); 947 + self->dx_ring = NULL; 948 + } 946 949 } 947 950 948 951 unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data)
+28 -10
drivers/net/ethernet/broadcom/bnxt/bnxt.c
··· 1748 1748 static void bnxt_deliver_skb(struct bnxt *bp, struct bnxt_napi *bnapi, 1749 1749 struct sk_buff *skb) 1750 1750 { 1751 + skb_mark_for_recycle(skb); 1752 + 1751 1753 if (skb->dev != bp->dev) { 1752 1754 /* this packet belongs to a vf-rep */ 1753 1755 bnxt_vf_rep_rx(bp, skb); 1754 1756 return; 1755 1757 } 1756 1758 skb_record_rx_queue(skb, bnapi->index); 1757 - skb_mark_for_recycle(skb); 1758 1759 napi_gro_receive(&bnapi->napi, skb); 1760 + } 1761 + 1762 + static bool bnxt_rx_ts_valid(struct bnxt *bp, u32 flags, 1763 + struct rx_cmp_ext *rxcmp1, u32 *cmpl_ts) 1764 + { 1765 + u32 ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); 1766 + 1767 + if (BNXT_PTP_RX_TS_VALID(flags)) 1768 + goto ts_valid; 1769 + if (!bp->ptp_all_rx_tstamp || !ts || !BNXT_ALL_RX_TS_VALID(flags)) 1770 + return false; 1771 + 1772 + ts_valid: 1773 + *cmpl_ts = ts; 1774 + return true; 1759 1775 } 1760 1776 1761 1777 /* returns the following: ··· 1799 1783 struct sk_buff *skb; 1800 1784 struct xdp_buff xdp; 1801 1785 u32 flags, misc; 1786 + u32 cmpl_ts; 1802 1787 void *data; 1803 1788 int rc = 0; 1804 1789 ··· 2022 2005 } 2023 2006 } 2024 2007 2025 - if (unlikely((flags & RX_CMP_FLAGS_ITYPES_MASK) == 2026 - RX_CMP_FLAGS_ITYPE_PTP_W_TS) || bp->ptp_all_rx_tstamp) { 2008 + if (bnxt_rx_ts_valid(bp, flags, rxcmp1, &cmpl_ts)) { 2027 2009 if (bp->flags & BNXT_FLAG_CHIP_P5) { 2028 - u32 cmpl_ts = le32_to_cpu(rxcmp1->rx_cmp_timestamp); 2029 2010 u64 ns, ts; 2030 2011 2031 2012 if (!bnxt_get_rx_ts_p5(bp, &ts, cmpl_ts)) { ··· 10746 10731 bnxt_free_mem(bp, irq_re_init); 10747 10732 } 10748 10733 10749 - int bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) 10734 + void bnxt_close_nic(struct bnxt *bp, bool irq_re_init, bool link_re_init) 10750 10735 { 10751 - int rc = 0; 10752 - 10753 10736 if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state)) { 10754 10737 /* If we get here, it means firmware reset is in progress 10755 10738 * while we are trying to close. We can safely proceed with ··· 10762 10749 10763 10750 #ifdef CONFIG_BNXT_SRIOV 10764 10751 if (bp->sriov_cfg) { 10752 + int rc; 10753 + 10765 10754 rc = wait_event_interruptible_timeout(bp->sriov_cfg_wait, 10766 10755 !bp->sriov_cfg, 10767 10756 BNXT_SRIOV_CFG_WAIT_TMO); 10768 - if (rc) 10769 - netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete!\n"); 10757 + if (!rc) 10758 + netdev_warn(bp->dev, "timeout waiting for SRIOV config operation to complete, proceeding to close!\n"); 10759 + else if (rc < 0) 10760 + netdev_warn(bp->dev, "SRIOV config operation interrupted, proceeding to close!\n"); 10770 10761 } 10771 10762 #endif 10772 10763 __bnxt_close_nic(bp, irq_re_init, link_re_init); 10773 - return rc; 10774 10764 } 10775 10765 10776 10766 static int bnxt_close(struct net_device *dev) ··· 13955 13939 rc = bnxt_hwrm_func_qcaps(bp); 13956 13940 if (rc) 13957 13941 goto resume_exit; 13942 + 13943 + bnxt_clear_reservations(bp, true); 13958 13944 13959 13945 if (bnxt_hwrm_func_drv_rgtr(bp, NULL, 0, false)) { 13960 13946 rc = -ENODEV;
+8 -2
drivers/net/ethernet/broadcom/bnxt/bnxt.h
··· 161 161 #define RX_CMP_FLAGS_ERROR (1 << 6) 162 162 #define RX_CMP_FLAGS_PLACEMENT (7 << 7) 163 163 #define RX_CMP_FLAGS_RSS_VALID (1 << 10) 164 - #define RX_CMP_FLAGS_UNUSED (1 << 11) 164 + #define RX_CMP_FLAGS_PKT_METADATA_PRESENT (1 << 11) 165 165 #define RX_CMP_FLAGS_ITYPES_SHIFT 12 166 166 #define RX_CMP_FLAGS_ITYPES_MASK 0xf000 167 167 #define RX_CMP_FLAGS_ITYPE_UNKNOWN (0 << 12) ··· 187 187 188 188 __le32 rx_cmp_rss_hash; 189 189 }; 190 + 191 + #define BNXT_PTP_RX_TS_VALID(flags) \ 192 + (((flags) & RX_CMP_FLAGS_ITYPES_MASK) == RX_CMP_FLAGS_ITYPE_PTP_W_TS) 193 + 194 + #define BNXT_ALL_RX_TS_VALID(flags) \ 195 + !((flags) & RX_CMP_FLAGS_PKT_METADATA_PRESENT) 190 196 191 197 #define RX_CMP_HASH_VALID(rxcmp) \ 192 198 ((rxcmp)->rx_cmp_len_flags_type & cpu_to_le32(RX_CMP_FLAGS_RSS_VALID)) ··· 2381 2375 int bnxt_half_open_nic(struct bnxt *bp); 2382 2376 void bnxt_half_close_nic(struct bnxt *bp); 2383 2377 void bnxt_reenable_sriov(struct bnxt *bp); 2384 - int bnxt_close_nic(struct bnxt *, bool, bool); 2378 + void bnxt_close_nic(struct bnxt *, bool, bool); 2385 2379 void bnxt_get_ring_err_stats(struct bnxt *bp, 2386 2380 struct bnxt_total_ring_err_stats *stats); 2387 2381 int bnxt_dbg_hwrm_rd_reg(struct bnxt *bp, u32 reg_off, u16 num_words,
+2 -9
drivers/net/ethernet/broadcom/bnxt/bnxt_devlink.c
··· 449 449 return -ENODEV; 450 450 } 451 451 bnxt_ulp_stop(bp); 452 - if (netif_running(bp->dev)) { 453 - rc = bnxt_close_nic(bp, true, true); 454 - if (rc) { 455 - NL_SET_ERR_MSG_MOD(extack, "Failed to close"); 456 - dev_close(bp->dev); 457 - rtnl_unlock(); 458 - break; 459 - } 460 - } 452 + if (netif_running(bp->dev)) 453 + bnxt_close_nic(bp, true, true); 461 454 bnxt_vf_reps_free(bp); 462 455 rc = bnxt_hwrm_func_drv_unrgtr(bp); 463 456 if (rc) {
+4 -15
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 165 165 reset_coalesce: 166 166 if (test_bit(BNXT_STATE_OPEN, &bp->state)) { 167 167 if (update_stats) { 168 - rc = bnxt_close_nic(bp, true, false); 169 - if (!rc) 170 - rc = bnxt_open_nic(bp, true, false); 168 + bnxt_close_nic(bp, true, false); 169 + rc = bnxt_open_nic(bp, true, false); 171 170 } else { 172 171 rc = bnxt_hwrm_set_coal(bp); 173 172 } ··· 971 972 * before PF unload 972 973 */ 973 974 } 974 - rc = bnxt_close_nic(bp, true, false); 975 - if (rc) { 976 - netdev_err(bp->dev, "Set channel failure rc :%x\n", 977 - rc); 978 - return rc; 979 - } 975 + bnxt_close_nic(bp, true, false); 980 976 } 981 977 982 978 if (sh) { ··· 4036 4042 bnxt_run_fw_tests(bp, test_mask, &test_results); 4037 4043 } else { 4038 4044 bnxt_ulp_stop(bp); 4039 - rc = bnxt_close_nic(bp, true, false); 4040 - if (rc) { 4041 - etest->flags |= ETH_TEST_FL_FAILED; 4042 - bnxt_ulp_start(bp, rc); 4043 - return; 4044 - } 4045 + bnxt_close_nic(bp, true, false); 4045 4046 bnxt_run_fw_tests(bp, test_mask, &test_results); 4046 4047 4047 4048 buf[BNXT_MACLPBK_TEST_IDX] = 1;
+2 -3
drivers/net/ethernet/broadcom/bnxt/bnxt_ptp.c
··· 521 521 522 522 if (netif_running(bp->dev)) { 523 523 if (ptp->rx_filter == HWTSTAMP_FILTER_ALL) { 524 - rc = bnxt_close_nic(bp, false, false); 525 - if (!rc) 526 - rc = bnxt_open_nic(bp, false, false); 524 + bnxt_close_nic(bp, false, false); 525 + rc = bnxt_open_nic(bp, false, false); 527 526 } else { 528 527 bnxt_ptp_cfg_tstamp_filters(bp); 529 528 }
+4 -3
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c
··· 139 139 err = dpsw_acl_add_entry(ethsw->mc_io, 0, ethsw->dpsw_handle, 140 140 filter_block->acl_id, acl_entry_cfg); 141 141 142 - dma_unmap_single(dev, acl_entry_cfg->key_iova, sizeof(cmd_buff), 142 + dma_unmap_single(dev, acl_entry_cfg->key_iova, 143 + DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE, 143 144 DMA_TO_DEVICE); 144 145 if (err) { 145 146 dev_err(dev, "dpsw_acl_add_entry() failed %d\n", err); ··· 182 181 err = dpsw_acl_remove_entry(ethsw->mc_io, 0, ethsw->dpsw_handle, 183 182 block->acl_id, acl_entry_cfg); 184 183 185 - dma_unmap_single(dev, acl_entry_cfg->key_iova, sizeof(cmd_buff), 186 - DMA_TO_DEVICE); 184 + dma_unmap_single(dev, acl_entry_cfg->key_iova, 185 + DPAA2_ETHSW_PORT_ACL_CMD_BUF_SIZE, DMA_TO_DEVICE); 187 186 if (err) { 188 187 dev_err(dev, "dpsw_acl_remove_entry() failed %d\n", err); 189 188 kfree(cmd_buff);
+2 -9
drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
··· 1998 1998 return notifier_from_errno(err); 1999 1999 } 2000 2000 2001 - static struct notifier_block dpaa2_switch_port_switchdev_nb; 2002 - static struct notifier_block dpaa2_switch_port_switchdev_blocking_nb; 2003 - 2004 2001 static int dpaa2_switch_port_bridge_join(struct net_device *netdev, 2005 2002 struct net_device *upper_dev, 2006 2003 struct netlink_ext_ack *extack) ··· 2040 2043 goto err_egress_flood; 2041 2044 2042 2045 err = switchdev_bridge_port_offload(netdev, netdev, NULL, 2043 - &dpaa2_switch_port_switchdev_nb, 2044 - &dpaa2_switch_port_switchdev_blocking_nb, 2045 - false, extack); 2046 + NULL, NULL, false, extack); 2046 2047 if (err) 2047 2048 goto err_switchdev_offload; 2048 2049 ··· 2074 2079 2075 2080 static void dpaa2_switch_port_pre_bridge_leave(struct net_device *netdev) 2076 2081 { 2077 - switchdev_bridge_port_unoffload(netdev, NULL, 2078 - &dpaa2_switch_port_switchdev_nb, 2079 - &dpaa2_switch_port_switchdev_blocking_nb); 2082 + switchdev_bridge_port_unoffload(netdev, NULL, NULL, NULL); 2080 2083 } 2081 2084 2082 2085 static int dpaa2_switch_port_bridge_leave(struct net_device *netdev)
+11 -16
drivers/net/ethernet/freescale/fec_main.c
··· 3731 3731 return 0; 3732 3732 } 3733 3733 3734 - static u16 fec_enet_get_raw_vlan_tci(struct sk_buff *skb) 3735 - { 3736 - struct vlan_ethhdr *vhdr; 3737 - unsigned short vlan_TCI = 0; 3738 - 3739 - if (skb->protocol == htons(ETH_P_ALL)) { 3740 - vhdr = (struct vlan_ethhdr *)(skb->data); 3741 - vlan_TCI = ntohs(vhdr->h_vlan_TCI); 3742 - } 3743 - 3744 - return vlan_TCI; 3745 - } 3746 - 3747 3734 static u16 fec_enet_select_queue(struct net_device *ndev, struct sk_buff *skb, 3748 3735 struct net_device *sb_dev) 3749 3736 { 3750 3737 struct fec_enet_private *fep = netdev_priv(ndev); 3751 - u16 vlan_tag; 3738 + u16 vlan_tag = 0; 3752 3739 3753 3740 if (!(fep->quirks & FEC_QUIRK_HAS_AVB)) 3754 3741 return netdev_pick_tx(ndev, skb, NULL); 3755 3742 3756 - vlan_tag = fec_enet_get_raw_vlan_tci(skb); 3757 - if (!vlan_tag) 3743 + /* VLAN is present in the payload.*/ 3744 + if (eth_type_vlan(skb->protocol)) { 3745 + struct vlan_ethhdr *vhdr = skb_vlan_eth_hdr(skb); 3746 + 3747 + vlan_tag = ntohs(vhdr->h_vlan_TCI); 3748 + /* VLAN is present in the skb but not yet pushed in the payload.*/ 3749 + } else if (skb_vlan_tag_present(skb)) { 3750 + vlan_tag = skb->vlan_tci; 3751 + } else { 3758 3752 return vlan_tag; 3753 + } 3759 3754 3760 3755 return fec_enet_vlan_pri_to_queue[vlan_tag >> 13]; 3761 3756 }
+1
drivers/net/ethernet/intel/iavf/iavf.h
··· 292 292 #define IAVF_FLAG_QUEUES_DISABLED BIT(17) 293 293 #define IAVF_FLAG_SETUP_NETDEV_FEATURES BIT(18) 294 294 #define IAVF_FLAG_REINIT_MSIX_NEEDED BIT(20) 295 + #define IAVF_FLAG_FDIR_ENABLED BIT(21) 295 296 /* duplicates for common code */ 296 297 #define IAVF_FLAG_DCB_ENABLED 0 297 298 /* flags for admin queue service task */
+18 -9
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 1061 1061 struct iavf_fdir_fltr *rule = NULL; 1062 1062 int ret = 0; 1063 1063 1064 - if (!FDIR_FLTR_SUPPORT(adapter)) 1064 + if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED)) 1065 1065 return -EOPNOTSUPP; 1066 1066 1067 1067 spin_lock_bh(&adapter->fdir_fltr_lock); ··· 1203 1203 unsigned int cnt = 0; 1204 1204 int val = 0; 1205 1205 1206 - if (!FDIR_FLTR_SUPPORT(adapter)) 1206 + if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED)) 1207 1207 return -EOPNOTSUPP; 1208 1208 1209 1209 cmd->data = IAVF_MAX_FDIR_FILTERS; ··· 1395 1395 int count = 50; 1396 1396 int err; 1397 1397 1398 - if (!FDIR_FLTR_SUPPORT(adapter)) 1398 + if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED)) 1399 1399 return -EOPNOTSUPP; 1400 1400 1401 1401 if (fsp->flow_type & FLOW_MAC_EXT) ··· 1436 1436 spin_lock_bh(&adapter->fdir_fltr_lock); 1437 1437 iavf_fdir_list_add_fltr(adapter, fltr); 1438 1438 adapter->fdir_active_fltr++; 1439 - fltr->state = IAVF_FDIR_FLTR_ADD_REQUEST; 1440 - adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; 1439 + if (adapter->link_up) { 1440 + fltr->state = IAVF_FDIR_FLTR_ADD_REQUEST; 1441 + adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; 1442 + } else { 1443 + fltr->state = IAVF_FDIR_FLTR_INACTIVE; 1444 + } 1441 1445 spin_unlock_bh(&adapter->fdir_fltr_lock); 1442 1446 1443 - mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); 1444 - 1447 + if (adapter->link_up) 1448 + mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); 1445 1449 ret: 1446 1450 if (err && fltr) 1447 1451 kfree(fltr); ··· 1467 1463 struct iavf_fdir_fltr *fltr = NULL; 1468 1464 int err = 0; 1469 1465 1470 - if (!FDIR_FLTR_SUPPORT(adapter)) 1466 + if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED)) 1471 1467 return -EOPNOTSUPP; 1472 1468 1473 1469 spin_lock_bh(&adapter->fdir_fltr_lock); ··· 1476 1472 if (fltr->state == IAVF_FDIR_FLTR_ACTIVE) { 1477 1473 fltr->state = IAVF_FDIR_FLTR_DEL_REQUEST; 1478 1474 adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; 1475 + } else if (fltr->state == IAVF_FDIR_FLTR_INACTIVE) { 1476 + list_del(&fltr->list); 1477 + kfree(fltr); 1478 + adapter->fdir_active_fltr--; 1479 + fltr = NULL; 1479 1480 } else { 1480 1481 err = -EBUSY; 1481 1482 } ··· 1789 1780 ret = 0; 1790 1781 break; 1791 1782 case ETHTOOL_GRXCLSRLCNT: 1792 - if (!FDIR_FLTR_SUPPORT(adapter)) 1783 + if (!(adapter->flags & IAVF_FLAG_FDIR_ENABLED)) 1793 1784 break; 1794 1785 spin_lock_bh(&adapter->fdir_fltr_lock); 1795 1786 cmd->rule_cnt = adapter->fdir_active_fltr;
+14 -1
drivers/net/ethernet/intel/iavf/iavf_fdir.h
··· 6 6 7 7 struct iavf_adapter; 8 8 9 - /* State of Flow Director filter */ 9 + /* State of Flow Director filter 10 + * 11 + * *_REQUEST states are used to mark filter to be sent to PF driver to perform 12 + * an action (either add or delete filter). *_PENDING states are an indication 13 + * that request was sent to PF and the driver is waiting for response. 14 + * 15 + * Both DELETE and DISABLE states are being used to delete a filter in PF. 16 + * The difference is that after a successful response filter in DEL_PENDING 17 + * state is being deleted from VF driver as well and filter in DIS_PENDING state 18 + * is being changed to INACTIVE state. 19 + */ 10 20 enum iavf_fdir_fltr_state_t { 11 21 IAVF_FDIR_FLTR_ADD_REQUEST, /* User requests to add filter */ 12 22 IAVF_FDIR_FLTR_ADD_PENDING, /* Filter pending add by the PF */ 13 23 IAVF_FDIR_FLTR_DEL_REQUEST, /* User requests to delete filter */ 14 24 IAVF_FDIR_FLTR_DEL_PENDING, /* Filter pending delete by the PF */ 25 + IAVF_FDIR_FLTR_DIS_REQUEST, /* Filter scheduled to be disabled */ 26 + IAVF_FDIR_FLTR_DIS_PENDING, /* Filter pending disable by the PF */ 27 + IAVF_FDIR_FLTR_INACTIVE, /* Filter inactive on link down */ 15 28 IAVF_FDIR_FLTR_ACTIVE, /* Filter is active */ 16 29 }; 17 30
+119 -60
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 277 277 } 278 278 279 279 /** 280 - * iavf_lock_timeout - try to lock mutex but give up after timeout 281 - * @lock: mutex that should be locked 282 - * @msecs: timeout in msecs 283 - * 284 - * Returns 0 on success, negative on failure 285 - **/ 286 - static int iavf_lock_timeout(struct mutex *lock, unsigned int msecs) 287 - { 288 - unsigned int wait, delay = 10; 289 - 290 - for (wait = 0; wait < msecs; wait += delay) { 291 - if (mutex_trylock(lock)) 292 - return 0; 293 - 294 - msleep(delay); 295 - } 296 - 297 - return -1; 298 - } 299 - 300 - /** 301 280 * iavf_schedule_reset - Set the flags and schedule a reset event 302 281 * @adapter: board private structure 303 282 * @flags: IAVF_FLAG_RESET_PENDING or IAVF_FLAG_RESET_NEEDED ··· 1332 1353 **/ 1333 1354 static void iavf_clear_fdir_filters(struct iavf_adapter *adapter) 1334 1355 { 1335 - struct iavf_fdir_fltr *fdir, *fdirtmp; 1356 + struct iavf_fdir_fltr *fdir; 1336 1357 1337 1358 /* remove all Flow Director filters */ 1338 1359 spin_lock_bh(&adapter->fdir_fltr_lock); 1339 - list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, 1340 - list) { 1360 + list_for_each_entry(fdir, &adapter->fdir_list_head, list) { 1341 1361 if (fdir->state == IAVF_FDIR_FLTR_ADD_REQUEST) { 1342 - list_del(&fdir->list); 1343 - kfree(fdir); 1344 - adapter->fdir_active_fltr--; 1345 - } else { 1346 - fdir->state = IAVF_FDIR_FLTR_DEL_REQUEST; 1362 + /* Cancel a request, keep filter as inactive */ 1363 + fdir->state = IAVF_FDIR_FLTR_INACTIVE; 1364 + } else if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING || 1365 + fdir->state == IAVF_FDIR_FLTR_ACTIVE) { 1366 + /* Disable filters which are active or have a pending 1367 + * request to PF to be added 1368 + */ 1369 + fdir->state = IAVF_FDIR_FLTR_DIS_REQUEST; 1347 1370 } 1348 1371 } 1349 1372 spin_unlock_bh(&adapter->fdir_fltr_lock); ··· 4094 4113 } 4095 4114 4096 4115 /** 4116 + * iavf_restore_fdir_filters 4117 + * @adapter: board private structure 4118 + * 4119 + * Restore existing FDIR filters when VF netdev comes back up. 4120 + **/ 4121 + static void iavf_restore_fdir_filters(struct iavf_adapter *adapter) 4122 + { 4123 + struct iavf_fdir_fltr *f; 4124 + 4125 + spin_lock_bh(&adapter->fdir_fltr_lock); 4126 + list_for_each_entry(f, &adapter->fdir_list_head, list) { 4127 + if (f->state == IAVF_FDIR_FLTR_DIS_REQUEST) { 4128 + /* Cancel a request, keep filter as active */ 4129 + f->state = IAVF_FDIR_FLTR_ACTIVE; 4130 + } else if (f->state == IAVF_FDIR_FLTR_DIS_PENDING || 4131 + f->state == IAVF_FDIR_FLTR_INACTIVE) { 4132 + /* Add filters which are inactive or have a pending 4133 + * request to PF to be deleted 4134 + */ 4135 + f->state = IAVF_FDIR_FLTR_ADD_REQUEST; 4136 + adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; 4137 + } 4138 + } 4139 + spin_unlock_bh(&adapter->fdir_fltr_lock); 4140 + } 4141 + 4142 + /** 4097 4143 * iavf_open - Called when a network interface is made active 4098 4144 * @netdev: network interface device structure 4099 4145 * ··· 4187 4179 4188 4180 spin_unlock_bh(&adapter->mac_vlan_list_lock); 4189 4181 4190 - /* Restore VLAN filters that were removed with IFF_DOWN */ 4182 + /* Restore filters that were removed with IFF_DOWN */ 4191 4183 iavf_restore_filters(adapter); 4184 + iavf_restore_fdir_filters(adapter); 4192 4185 4193 4186 iavf_configure(adapter); 4194 4187 ··· 4320 4311 return ret; 4321 4312 } 4322 4313 4314 + /** 4315 + * iavf_disable_fdir - disable Flow Director and clear existing filters 4316 + * @adapter: board private structure 4317 + **/ 4318 + static void iavf_disable_fdir(struct iavf_adapter *adapter) 4319 + { 4320 + struct iavf_fdir_fltr *fdir, *fdirtmp; 4321 + bool del_filters = false; 4322 + 4323 + adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED; 4324 + 4325 + /* remove all Flow Director filters */ 4326 + spin_lock_bh(&adapter->fdir_fltr_lock); 4327 + list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head, 4328 + list) { 4329 + if (fdir->state == IAVF_FDIR_FLTR_ADD_REQUEST || 4330 + fdir->state == IAVF_FDIR_FLTR_INACTIVE) { 4331 + /* Delete filters not registered in PF */ 4332 + list_del(&fdir->list); 4333 + kfree(fdir); 4334 + adapter->fdir_active_fltr--; 4335 + } else if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING || 4336 + fdir->state == IAVF_FDIR_FLTR_DIS_REQUEST || 4337 + fdir->state == IAVF_FDIR_FLTR_ACTIVE) { 4338 + /* Filters registered in PF, schedule their deletion */ 4339 + fdir->state = IAVF_FDIR_FLTR_DEL_REQUEST; 4340 + del_filters = true; 4341 + } else if (fdir->state == IAVF_FDIR_FLTR_DIS_PENDING) { 4342 + /* Request to delete filter already sent to PF, change 4343 + * state to DEL_PENDING to delete filter after PF's 4344 + * response, not set as INACTIVE 4345 + */ 4346 + fdir->state = IAVF_FDIR_FLTR_DEL_PENDING; 4347 + } 4348 + } 4349 + spin_unlock_bh(&adapter->fdir_fltr_lock); 4350 + 4351 + if (del_filters) { 4352 + adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER; 4353 + mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0); 4354 + } 4355 + } 4356 + 4323 4357 #define NETIF_VLAN_OFFLOAD_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \ 4324 4358 NETIF_F_HW_VLAN_CTAG_TX | \ 4325 4359 NETIF_F_HW_VLAN_STAG_RX | \ ··· 4387 4335 if (CRC_OFFLOAD_ALLOWED(adapter) && 4388 4336 ((netdev->features & NETIF_F_RXFCS) ^ (features & NETIF_F_RXFCS))) 4389 4337 iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 4338 + 4339 + if ((netdev->features & NETIF_F_NTUPLE) ^ (features & NETIF_F_NTUPLE)) { 4340 + if (features & NETIF_F_NTUPLE) 4341 + adapter->flags |= IAVF_FLAG_FDIR_ENABLED; 4342 + else 4343 + iavf_disable_fdir(adapter); 4344 + } 4390 4345 4391 4346 return 0; 4392 4347 } ··· 4744 4685 4745 4686 features = iavf_fix_netdev_vlan_features(adapter, features); 4746 4687 4688 + if (!FDIR_FLTR_SUPPORT(adapter)) 4689 + features &= ~NETIF_F_NTUPLE; 4690 + 4747 4691 return iavf_fix_strip_features(adapter, features); 4748 4692 } 4749 4693 ··· 4864 4802 if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN) 4865 4803 netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; 4866 4804 4805 + if (FDIR_FLTR_SUPPORT(adapter)) { 4806 + netdev->hw_features |= NETIF_F_NTUPLE; 4807 + netdev->features |= NETIF_F_NTUPLE; 4808 + adapter->flags |= IAVF_FLAG_FDIR_ENABLED; 4809 + } 4810 + 4867 4811 netdev->priv_flags |= IFF_UNICAST_FLT; 4868 4812 4869 4813 /* Do not turn on offloads when they are requested to be turned off. ··· 4891 4823 } 4892 4824 4893 4825 return 0; 4894 - } 4895 - 4896 - /** 4897 - * iavf_shutdown - Shutdown the device in preparation for a reboot 4898 - * @pdev: pci device structure 4899 - **/ 4900 - static void iavf_shutdown(struct pci_dev *pdev) 4901 - { 4902 - struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev); 4903 - struct net_device *netdev = adapter->netdev; 4904 - 4905 - netif_device_detach(netdev); 4906 - 4907 - if (netif_running(netdev)) 4908 - iavf_close(netdev); 4909 - 4910 - if (iavf_lock_timeout(&adapter->crit_lock, 5000)) 4911 - dev_warn(&adapter->pdev->dev, "%s: failed to acquire crit_lock\n", __func__); 4912 - /* Prevent the watchdog from running. */ 4913 - iavf_change_state(adapter, __IAVF_REMOVE); 4914 - adapter->aq_required = 0; 4915 - mutex_unlock(&adapter->crit_lock); 4916 - 4917 - #ifdef CONFIG_PM 4918 - pci_save_state(pdev); 4919 - 4920 - #endif 4921 - pci_disable_device(pdev); 4922 4826 } 4923 4827 4924 4828 /** ··· 5103 5063 **/ 5104 5064 static void iavf_remove(struct pci_dev *pdev) 5105 5065 { 5106 - struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev); 5107 5066 struct iavf_fdir_fltr *fdir, *fdirtmp; 5108 5067 struct iavf_vlan_filter *vlf, *vlftmp; 5109 5068 struct iavf_cloud_filter *cf, *cftmp; 5110 5069 struct iavf_adv_rss *rss, *rsstmp; 5111 5070 struct iavf_mac_filter *f, *ftmp; 5071 + struct iavf_adapter *adapter; 5112 5072 struct net_device *netdev; 5113 5073 struct iavf_hw *hw; 5114 5074 5115 - netdev = adapter->netdev; 5075 + /* Don't proceed with remove if netdev is already freed */ 5076 + netdev = pci_get_drvdata(pdev); 5077 + if (!netdev) 5078 + return; 5079 + 5080 + adapter = iavf_pdev_to_adapter(pdev); 5116 5081 hw = &adapter->hw; 5117 5082 5118 5083 if (test_and_set_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) ··· 5229 5184 5230 5185 destroy_workqueue(adapter->wq); 5231 5186 5187 + pci_set_drvdata(pdev, NULL); 5188 + 5232 5189 free_netdev(netdev); 5233 5190 5234 5191 pci_disable_device(pdev); 5192 + } 5193 + 5194 + /** 5195 + * iavf_shutdown - Shutdown the device in preparation for a reboot 5196 + * @pdev: pci device structure 5197 + **/ 5198 + static void iavf_shutdown(struct pci_dev *pdev) 5199 + { 5200 + iavf_remove(pdev); 5201 + 5202 + if (system_state == SYSTEM_POWER_OFF) 5203 + pci_set_power_state(pdev, PCI_D3hot); 5235 5204 } 5236 5205 5237 5206 static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);
+67 -4
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
··· 1735 1735 **/ 1736 1736 void iavf_del_fdir_filter(struct iavf_adapter *adapter) 1737 1737 { 1738 + struct virtchnl_fdir_del f = {}; 1738 1739 struct iavf_fdir_fltr *fdir; 1739 - struct virtchnl_fdir_del f; 1740 1740 bool process_fltr = false; 1741 1741 int len; 1742 1742 ··· 1753 1753 list_for_each_entry(fdir, &adapter->fdir_list_head, list) { 1754 1754 if (fdir->state == IAVF_FDIR_FLTR_DEL_REQUEST) { 1755 1755 process_fltr = true; 1756 - memset(&f, 0, len); 1757 1756 f.vsi_id = fdir->vc_add_msg.vsi_id; 1758 1757 f.flow_id = fdir->flow_id; 1759 1758 fdir->state = IAVF_FDIR_FLTR_DEL_PENDING; 1759 + break; 1760 + } else if (fdir->state == IAVF_FDIR_FLTR_DIS_REQUEST) { 1761 + process_fltr = true; 1762 + f.vsi_id = fdir->vc_add_msg.vsi_id; 1763 + f.flow_id = fdir->flow_id; 1764 + fdir->state = IAVF_FDIR_FLTR_DIS_PENDING; 1760 1765 break; 1761 1766 } 1762 1767 } ··· 1904 1899 netdev->features |= NETIF_F_HW_VLAN_CTAG_RX; 1905 1900 else 1906 1901 netdev->features &= ~NETIF_F_HW_VLAN_CTAG_RX; 1902 + } 1903 + 1904 + /** 1905 + * iavf_activate_fdir_filters - Reactivate all FDIR filters after a reset 1906 + * @adapter: private adapter structure 1907 + * 1908 + * Called after a reset to re-add all FDIR filters and delete some of them 1909 + * if they were pending to be deleted. 1910 + */ 1911 + static void iavf_activate_fdir_filters(struct iavf_adapter *adapter) 1912 + { 1913 + struct iavf_fdir_fltr *f, *ftmp; 1914 + bool add_filters = false; 1915 + 1916 + spin_lock_bh(&adapter->fdir_fltr_lock); 1917 + list_for_each_entry_safe(f, ftmp, &adapter->fdir_list_head, list) { 1918 + if (f->state == IAVF_FDIR_FLTR_ADD_REQUEST || 1919 + f->state == IAVF_FDIR_FLTR_ADD_PENDING || 1920 + f->state == IAVF_FDIR_FLTR_ACTIVE) { 1921 + /* All filters and requests have been removed in PF, 1922 + * restore them 1923 + */ 1924 + f->state = IAVF_FDIR_FLTR_ADD_REQUEST; 1925 + add_filters = true; 1926 + } else if (f->state == IAVF_FDIR_FLTR_DIS_REQUEST || 1927 + f->state == IAVF_FDIR_FLTR_DIS_PENDING) { 1928 + /* Link down state, leave filters as inactive */ 1929 + f->state = IAVF_FDIR_FLTR_INACTIVE; 1930 + } else if (f->state == IAVF_FDIR_FLTR_DEL_REQUEST || 1931 + f->state == IAVF_FDIR_FLTR_DEL_PENDING) { 1932 + /* Delete filters that were pending to be deleted, the 1933 + * list on PF is already cleared after a reset 1934 + */ 1935 + list_del(&f->list); 1936 + kfree(f); 1937 + adapter->fdir_active_fltr--; 1938 + } 1939 + } 1940 + spin_unlock_bh(&adapter->fdir_fltr_lock); 1941 + 1942 + if (add_filters) 1943 + adapter->aq_required |= IAVF_FLAG_AQ_ADD_FDIR_FILTER; 1907 1944 } 1908 1945 1909 1946 /** ··· 2125 2078 spin_lock_bh(&adapter->fdir_fltr_lock); 2126 2079 list_for_each_entry(fdir, &adapter->fdir_list_head, 2127 2080 list) { 2128 - if (fdir->state == IAVF_FDIR_FLTR_DEL_PENDING) { 2081 + if (fdir->state == IAVF_FDIR_FLTR_DEL_PENDING || 2082 + fdir->state == IAVF_FDIR_FLTR_DIS_PENDING) { 2129 2083 fdir->state = IAVF_FDIR_FLTR_ACTIVE; 2130 2084 dev_info(&adapter->pdev->dev, "Failed to del Flow Director filter, error %s\n", 2131 2085 iavf_stat_str(&adapter->hw, ··· 2261 2213 } 2262 2214 2263 2215 spin_unlock_bh(&adapter->mac_vlan_list_lock); 2216 + 2217 + iavf_activate_fdir_filters(adapter); 2264 2218 2265 2219 iavf_parse_vf_resource_msg(adapter); 2266 2220 ··· 2440 2390 list_for_each_entry_safe(fdir, fdir_tmp, &adapter->fdir_list_head, 2441 2391 list) { 2442 2392 if (fdir->state == IAVF_FDIR_FLTR_DEL_PENDING) { 2443 - if (del_fltr->status == VIRTCHNL_FDIR_SUCCESS) { 2393 + if (del_fltr->status == VIRTCHNL_FDIR_SUCCESS || 2394 + del_fltr->status == 2395 + VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST) { 2444 2396 dev_info(&adapter->pdev->dev, "Flow Director filter with location %u is deleted\n", 2445 2397 fdir->loc); 2446 2398 list_del(&fdir->list); ··· 2451 2399 } else { 2452 2400 fdir->state = IAVF_FDIR_FLTR_ACTIVE; 2453 2401 dev_info(&adapter->pdev->dev, "Failed to delete Flow Director filter with status: %d\n", 2402 + del_fltr->status); 2403 + iavf_print_fdir_fltr(adapter, fdir); 2404 + } 2405 + } else if (fdir->state == IAVF_FDIR_FLTR_DIS_PENDING) { 2406 + if (del_fltr->status == VIRTCHNL_FDIR_SUCCESS || 2407 + del_fltr->status == 2408 + VIRTCHNL_FDIR_FAILURE_RULE_NONEXIST) { 2409 + fdir->state = IAVF_FDIR_FLTR_INACTIVE; 2410 + } else { 2411 + fdir->state = IAVF_FDIR_FLTR_ACTIVE; 2412 + dev_info(&adapter->pdev->dev, "Failed to disable Flow Director filter with status: %d\n", 2454 2413 del_fltr->status); 2455 2414 iavf_print_fdir_fltr(adapter, fdir); 2456 2415 }
+15 -10
drivers/net/ethernet/marvell/octeon_ep/octep_main.c
··· 1193 1193 if (ret) 1194 1194 return ret; 1195 1195 1196 + INIT_WORK(&oct->tx_timeout_task, octep_tx_timeout_task); 1197 + INIT_WORK(&oct->ctrl_mbox_task, octep_ctrl_mbox_task); 1198 + INIT_DELAYED_WORK(&oct->intr_poll_task, octep_intr_poll_task); 1199 + oct->poll_non_ioq_intr = true; 1200 + queue_delayed_work(octep_wq, &oct->intr_poll_task, 1201 + msecs_to_jiffies(OCTEP_INTR_POLL_TIME_MSECS)); 1202 + 1196 1203 atomic_set(&oct->hb_miss_cnt, 0); 1197 1204 INIT_DELAYED_WORK(&oct->hb_task, octep_hb_timeout_task); 1198 1205 ··· 1265 1258 1266 1259 pci_read_config_byte(pdev, (pos + 8), &status); 1267 1260 dev_info(&pdev->dev, "Firmware ready status = %u\n", status); 1268 - return status; 1261 + #define FW_STATUS_READY 1ULL 1262 + return status == FW_STATUS_READY; 1269 1263 } 1270 1264 return false; 1271 1265 } ··· 1333 1325 goto err_octep_config; 1334 1326 } 1335 1327 1336 - octep_ctrl_net_get_info(octep_dev, OCTEP_CTRL_NET_INVALID_VFID, 1337 - &octep_dev->conf->fw_info); 1328 + err = octep_ctrl_net_get_info(octep_dev, OCTEP_CTRL_NET_INVALID_VFID, 1329 + &octep_dev->conf->fw_info); 1330 + if (err) { 1331 + dev_err(&pdev->dev, "Failed to get firmware info\n"); 1332 + goto register_dev_err; 1333 + } 1338 1334 dev_info(&octep_dev->pdev->dev, "Heartbeat interval %u msecs Heartbeat miss count %u\n", 1339 1335 octep_dev->conf->fw_info.hb_interval, 1340 1336 octep_dev->conf->fw_info.hb_miss_count); 1341 1337 queue_delayed_work(octep_wq, &octep_dev->hb_task, 1342 1338 msecs_to_jiffies(octep_dev->conf->fw_info.hb_interval)); 1343 - 1344 - INIT_WORK(&octep_dev->tx_timeout_task, octep_tx_timeout_task); 1345 - INIT_WORK(&octep_dev->ctrl_mbox_task, octep_ctrl_mbox_task); 1346 - INIT_DELAYED_WORK(&octep_dev->intr_poll_task, octep_intr_poll_task); 1347 - octep_dev->poll_non_ioq_intr = true; 1348 - queue_delayed_work(octep_wq, &octep_dev->intr_poll_task, 1349 - msecs_to_jiffies(OCTEP_INTR_POLL_TIME_MSECS)); 1350 1339 1351 1340 netdev->netdev_ops = &octep_netdev_ops; 1352 1341 octep_set_ethtool_ops(netdev);
+7 -4
drivers/net/ethernet/marvell/octeontx2/af/rpm.c
··· 373 373 cfg |= RPMX_MTI_MAC100X_COMMAND_CONFIG_TX_P_DISABLE; 374 374 rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); 375 375 376 + /* Disable forward pause to driver */ 377 + cfg = rpm_read(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG); 378 + cfg &= ~RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD; 379 + rpm_write(rpm, lmac_id, RPMX_MTI_MAC100X_COMMAND_CONFIG, cfg); 380 + 376 381 /* Enable channel mask for all LMACS */ 377 382 if (is_dev_rpm2(rpm)) 378 383 rpm_write(rpm, lmac_id, RPM2_CMR_CHAN_MSK_OR, 0xffff); ··· 621 616 622 617 if (rx_pause) { 623 618 cfg &= ~(RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE | 624 - RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE | 625 - RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD); 619 + RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE); 626 620 } else { 627 621 cfg |= (RPMX_MTI_MAC100X_COMMAND_CONFIG_RX_P_DISABLE | 628 - RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE | 629 - RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_FWD); 622 + RPMX_MTI_MAC100X_COMMAND_CONFIG_PAUSE_IGNORE); 630 623 } 631 624 632 625 if (tx_pause) {
+1 -4
drivers/net/ethernet/marvell/octeontx2/af/rvu_devlink.c
··· 538 538 539 539 rvu_dl->devlink_wq = create_workqueue("rvu_devlink_wq"); 540 540 if (!rvu_dl->devlink_wq) 541 - goto err; 541 + return -ENOMEM; 542 542 543 543 INIT_WORK(&rvu_reporters->intr_work, rvu_nix_intr_work); 544 544 INIT_WORK(&rvu_reporters->gen_work, rvu_nix_gen_work); ··· 546 546 INIT_WORK(&rvu_reporters->ras_work, rvu_nix_ras_work); 547 547 548 548 return 0; 549 - err: 550 - rvu_nix_health_reporters_destroy(rvu_dl); 551 - return -ENOMEM; 552 549 } 553 550 554 551 static int rvu_nix_health_reporters_create(struct rvu_devlink *rvu_dl)
+44 -11
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
··· 671 671 int blkaddr, ucast_idx, index; 672 672 struct nix_rx_action action = { 0 }; 673 673 u64 relaxed_mask; 674 + u8 flow_key_alg; 674 675 675 676 if (!hw->cap.nix_rx_multicast && is_cgx_vf(rvu, pcifunc)) 676 677 return; ··· 701 700 *(u64 *)&action = 0; 702 701 action.op = NIX_RX_ACTIONOP_UCAST; 703 702 } 703 + 704 + flow_key_alg = action.flow_key_alg; 704 705 705 706 /* RX_ACTION set to MCAST for CGX PF's */ 706 707 if (hw->cap.nix_rx_multicast && pfvf->use_mce_list && ··· 743 740 req.vf = pcifunc; 744 741 req.index = action.index; 745 742 req.match_id = action.match_id; 746 - req.flow_key_alg = action.flow_key_alg; 743 + req.flow_key_alg = flow_key_alg; 747 744 748 745 rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp); 749 746 } ··· 857 854 u8 mac_addr[ETH_ALEN] = { 0 }; 858 855 struct nix_rx_action action = { 0 }; 859 856 struct rvu_pfvf *pfvf; 857 + u8 flow_key_alg; 860 858 u16 vf_func; 861 859 862 860 /* Only CGX PF/VF can add allmulticast entry */ ··· 892 888 *(u64 *)&action = npc_get_mcam_action(rvu, mcam, 893 889 blkaddr, ucast_idx); 894 890 891 + flow_key_alg = action.flow_key_alg; 895 892 if (action.op != NIX_RX_ACTIONOP_RSS) { 896 893 *(u64 *)&action = 0; 897 894 action.op = NIX_RX_ACTIONOP_UCAST; ··· 929 924 req.vf = pcifunc | vf_func; 930 925 req.index = action.index; 931 926 req.match_id = action.match_id; 932 - req.flow_key_alg = action.flow_key_alg; 927 + req.flow_key_alg = flow_key_alg; 933 928 934 929 rvu_mbox_handler_npc_install_flow(rvu, &req, &rsp); 935 930 } ··· 995 990 mutex_unlock(&mcam->lock); 996 991 } 997 992 993 + static void npc_update_rx_action_with_alg_idx(struct rvu *rvu, struct nix_rx_action action, 994 + struct rvu_pfvf *pfvf, int mcam_index, int blkaddr, 995 + int alg_idx) 996 + 997 + { 998 + struct npc_mcam *mcam = &rvu->hw->mcam; 999 + struct rvu_hwinfo *hw = rvu->hw; 1000 + int bank, op_rss; 1001 + 1002 + if (!is_mcam_entry_enabled(rvu, mcam, blkaddr, mcam_index)) 1003 + return; 1004 + 1005 + op_rss = (!hw->cap.nix_rx_multicast || !pfvf->use_mce_list); 1006 + 1007 + bank = npc_get_bank(mcam, mcam_index); 1008 + mcam_index &= (mcam->banksize - 1); 1009 + 1010 + /* If Rx action is MCAST update only RSS algorithm index */ 1011 + if (!op_rss) { 1012 + *(u64 *)&action = rvu_read64(rvu, blkaddr, 1013 + NPC_AF_MCAMEX_BANKX_ACTION(mcam_index, bank)); 1014 + 1015 + action.flow_key_alg = alg_idx; 1016 + } 1017 + rvu_write64(rvu, blkaddr, 1018 + NPC_AF_MCAMEX_BANKX_ACTION(mcam_index, bank), *(u64 *)&action); 1019 + } 1020 + 998 1021 void rvu_npc_update_flowkey_alg_idx(struct rvu *rvu, u16 pcifunc, int nixlf, 999 1022 int group, int alg_idx, int mcam_index) 1000 1023 { 1001 1024 struct npc_mcam *mcam = &rvu->hw->mcam; 1002 - struct rvu_hwinfo *hw = rvu->hw; 1003 1025 struct nix_rx_action action; 1004 1026 int blkaddr, index, bank; 1005 1027 struct rvu_pfvf *pfvf; ··· 1082 1050 /* If PF's promiscuous entry is enabled, 1083 1051 * Set RSS action for that entry as well 1084 1052 */ 1085 - if ((!hw->cap.nix_rx_multicast || !pfvf->use_mce_list) && 1086 - is_mcam_entry_enabled(rvu, mcam, blkaddr, index)) { 1087 - bank = npc_get_bank(mcam, index); 1088 - index &= (mcam->banksize - 1); 1053 + npc_update_rx_action_with_alg_idx(rvu, action, pfvf, index, blkaddr, 1054 + alg_idx); 1089 1055 1090 - rvu_write64(rvu, blkaddr, 1091 - NPC_AF_MCAMEX_BANKX_ACTION(index, bank), 1092 - *(u64 *)&action); 1093 - } 1056 + index = npc_get_nixlf_mcam_index(mcam, pcifunc, 1057 + nixlf, NIXLF_ALLMULTI_ENTRY); 1058 + /* If PF's allmulti entry is enabled, 1059 + * Set RSS action for that entry as well 1060 + */ 1061 + npc_update_rx_action_with_alg_idx(rvu, action, pfvf, index, blkaddr, 1062 + alg_idx); 1094 1063 } 1095 1064 1096 1065 void npc_enadis_default_mce_entry(struct rvu *rvu, u16 pcifunc,
+22 -3
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 1650 1650 mutex_unlock(&mbox->lock); 1651 1651 } 1652 1652 1653 + static bool otx2_promisc_use_mce_list(struct otx2_nic *pfvf) 1654 + { 1655 + int vf; 1656 + 1657 + /* The AF driver will determine whether to allow the VF netdev or not */ 1658 + if (is_otx2_vf(pfvf->pcifunc)) 1659 + return true; 1660 + 1661 + /* check if there are any trusted VFs associated with the PF netdev */ 1662 + for (vf = 0; vf < pci_num_vf(pfvf->pdev); vf++) 1663 + if (pfvf->vf_configs[vf].trusted) 1664 + return true; 1665 + return false; 1666 + } 1667 + 1653 1668 static void otx2_do_set_rx_mode(struct otx2_nic *pf) 1654 1669 { 1655 1670 struct net_device *netdev = pf->netdev; ··· 1697 1682 if (netdev->flags & (IFF_ALLMULTI | IFF_MULTICAST)) 1698 1683 req->mode |= NIX_RX_MODE_ALLMULTI; 1699 1684 1700 - req->mode |= NIX_RX_MODE_USE_MCE; 1685 + if (otx2_promisc_use_mce_list(pf)) 1686 + req->mode |= NIX_RX_MODE_USE_MCE; 1701 1687 1702 1688 otx2_sync_mbox_msg(&pf->mbox); 1703 1689 mutex_unlock(&pf->mbox.lock); ··· 2707 2691 pf->vf_configs[vf].trusted = enable; 2708 2692 rc = otx2_set_vf_permissions(pf, vf, OTX2_TRUSTED_VF); 2709 2693 2710 - if (rc) 2694 + if (rc) { 2711 2695 pf->vf_configs[vf].trusted = !enable; 2712 - else 2696 + } else { 2713 2697 netdev_info(pf->netdev, "VF %d is %strusted\n", 2714 2698 vf, enable ? "" : "not "); 2699 + otx2_set_rx_mode(netdev); 2700 + } 2701 + 2715 2702 return rc; 2716 2703 } 2717 2704
+1
drivers/net/ethernet/mellanox/mlx5/core/en.h
··· 826 826 MLX5E_STATE_DESTROYING, 827 827 MLX5E_STATE_XDP_TX_ENABLED, 828 828 MLX5E_STATE_XDP_ACTIVE, 829 + MLX5E_STATE_CHANNELS_ACTIVE, 829 830 }; 830 831 831 832 struct mlx5e_modify_sq_param {
+6
drivers/net/ethernet/mellanox/mlx5/core/en/tc/post_act.c
··· 83 83 struct mlx5_flow_spec *spec; 84 84 int err; 85 85 86 + if (IS_ERR(post_act)) 87 + return PTR_ERR(post_act); 88 + 86 89 spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 87 90 if (!spec) 88 91 return -ENOMEM; ··· 113 110 { 114 111 struct mlx5e_post_act_handle *handle; 115 112 int err; 113 + 114 + if (IS_ERR(post_act)) 115 + return ERR_CAST(post_act); 116 116 117 117 handle = kzalloc(sizeof(*handle), GFP_KERNEL); 118 118 if (!handle)
+40 -16
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c
··· 121 121 if (x->xso.type == XFRM_DEV_OFFLOAD_CRYPTO) 122 122 esn_msb = xfrm_replay_seqhi(x, htonl(seq_bottom)); 123 123 124 - sa_entry->esn_state.esn = esn; 124 + if (sa_entry->esn_state.esn_msb) 125 + sa_entry->esn_state.esn = esn; 126 + else 127 + /* According to RFC4303, section "3.3.3. Sequence Number Generation", 128 + * the first packet sent using a given SA will contain a sequence 129 + * number of 1. 130 + */ 131 + sa_entry->esn_state.esn = max_t(u32, esn, 1); 125 132 sa_entry->esn_state.esn_msb = esn_msb; 126 133 127 134 if (unlikely(overlap && seq_bottom < MLX5E_IPSEC_ESN_SCOPE_MID)) { ··· 342 335 attrs->replay_esn.esn = sa_entry->esn_state.esn; 343 336 attrs->replay_esn.esn_msb = sa_entry->esn_state.esn_msb; 344 337 attrs->replay_esn.overlap = sa_entry->esn_state.overlap; 338 + switch (x->replay_esn->replay_window) { 339 + case 32: 340 + attrs->replay_esn.replay_window = 341 + MLX5_IPSEC_ASO_REPLAY_WIN_32BIT; 342 + break; 343 + case 64: 344 + attrs->replay_esn.replay_window = 345 + MLX5_IPSEC_ASO_REPLAY_WIN_64BIT; 346 + break; 347 + case 128: 348 + attrs->replay_esn.replay_window = 349 + MLX5_IPSEC_ASO_REPLAY_WIN_128BIT; 350 + break; 351 + case 256: 352 + attrs->replay_esn.replay_window = 353 + MLX5_IPSEC_ASO_REPLAY_WIN_256BIT; 354 + break; 355 + default: 356 + WARN_ON(true); 357 + return; 358 + } 345 359 } 346 360 347 361 attrs->dir = x->xso.dir; ··· 935 907 return; 936 908 937 909 mlx5e_accel_ipsec_fs_cleanup(ipsec); 938 - if (mlx5_ipsec_device_caps(priv->mdev) & MLX5_IPSEC_CAP_TUNNEL) 910 + if (ipsec->netevent_nb.notifier_call) { 939 911 unregister_netevent_notifier(&ipsec->netevent_nb); 940 - if (mlx5_ipsec_device_caps(priv->mdev) & MLX5_IPSEC_CAP_PACKET_OFFLOAD) 912 + ipsec->netevent_nb.notifier_call = NULL; 913 + } 914 + if (ipsec->aso) 941 915 mlx5e_ipsec_aso_cleanup(ipsec); 942 916 destroy_workqueue(ipsec->wq); 943 917 kfree(ipsec); ··· 1048 1018 } 1049 1019 } 1050 1020 1021 + if (x->xdo.type == XFRM_DEV_OFFLOAD_PACKET && 1022 + !(mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_PACKET_OFFLOAD)) { 1023 + NL_SET_ERR_MSG_MOD(extack, "Packet offload is not supported"); 1024 + return -EINVAL; 1025 + } 1026 + 1051 1027 return 0; 1052 1028 } 1053 1029 ··· 1149 1113 .xdo_dev_state_free = mlx5e_xfrm_free_state, 1150 1114 .xdo_dev_offload_ok = mlx5e_ipsec_offload_ok, 1151 1115 .xdo_dev_state_advance_esn = mlx5e_xfrm_advance_esn_state, 1152 - }; 1153 - 1154 - static const struct xfrmdev_ops mlx5e_ipsec_packet_xfrmdev_ops = { 1155 - .xdo_dev_state_add = mlx5e_xfrm_add_state, 1156 - .xdo_dev_state_delete = mlx5e_xfrm_del_state, 1157 - .xdo_dev_state_free = mlx5e_xfrm_free_state, 1158 - .xdo_dev_offload_ok = mlx5e_ipsec_offload_ok, 1159 - .xdo_dev_state_advance_esn = mlx5e_xfrm_advance_esn_state, 1160 1116 1161 1117 .xdo_dev_state_update_curlft = mlx5e_xfrm_update_curlft, 1162 1118 .xdo_dev_policy_add = mlx5e_xfrm_add_policy, ··· 1166 1138 1167 1139 mlx5_core_info(mdev, "mlx5e: IPSec ESP acceleration enabled\n"); 1168 1140 1169 - if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_PACKET_OFFLOAD) 1170 - netdev->xfrmdev_ops = &mlx5e_ipsec_packet_xfrmdev_ops; 1171 - else 1172 - netdev->xfrmdev_ops = &mlx5e_ipsec_xfrmdev_ops; 1173 - 1141 + netdev->xfrmdev_ops = &mlx5e_ipsec_xfrmdev_ops; 1174 1142 netdev->features |= NETIF_F_HW_ESP; 1175 1143 netdev->hw_enc_features |= NETIF_F_HW_ESP; 1176 1144
+9 -13
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.h
··· 189 189 u32 refcnt; 190 190 }; 191 191 192 + struct mlx5e_ipsec_drop { 193 + struct mlx5_flow_handle *rule; 194 + struct mlx5_fc *fc; 195 + }; 196 + 192 197 struct mlx5e_ipsec_rule { 193 198 struct mlx5_flow_handle *rule; 194 199 struct mlx5_modify_hdr *modify_hdr; 195 200 struct mlx5_pkt_reformat *pkt_reformat; 196 201 struct mlx5_fc *fc; 202 + struct mlx5e_ipsec_drop replay; 203 + struct mlx5e_ipsec_drop auth; 204 + struct mlx5e_ipsec_drop trailer; 197 205 }; 198 206 199 207 struct mlx5e_ipsec_miss { 200 208 struct mlx5_flow_group *group; 201 209 struct mlx5_flow_handle *rule; 202 - }; 203 - 204 - struct mlx5e_ipsec_rx { 205 - struct mlx5e_ipsec_ft ft; 206 - struct mlx5e_ipsec_miss pol; 207 - struct mlx5e_ipsec_miss sa; 208 - struct mlx5e_ipsec_rule status; 209 - struct mlx5e_ipsec_miss status_drop; 210 - struct mlx5_fc *status_drop_cnt; 211 - struct mlx5e_ipsec_fc *fc; 212 - struct mlx5_fs_chains *chains; 213 - u8 allow_tunnel_mode : 1; 214 - struct xarray ipsec_obj_id_map; 215 210 }; 216 211 217 212 struct mlx5e_ipsec_tx_create_attr { ··· 243 248 struct mlx5_ipsec_fs *roce; 244 249 u8 is_uplink_rep: 1; 245 250 struct mlx5e_ipsec_mpv_work mpv_work; 251 + struct xarray ipsec_obj_id_map; 246 252 }; 247 253 248 254 struct mlx5e_ipsec_esn_state {
+381 -66
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_fs.c
··· 32 32 u8 allow_tunnel_mode : 1; 33 33 }; 34 34 35 + struct mlx5e_ipsec_status_checks { 36 + struct mlx5_flow_group *drop_all_group; 37 + struct mlx5e_ipsec_drop all; 38 + }; 39 + 40 + struct mlx5e_ipsec_rx { 41 + struct mlx5e_ipsec_ft ft; 42 + struct mlx5e_ipsec_miss pol; 43 + struct mlx5e_ipsec_miss sa; 44 + struct mlx5e_ipsec_rule status; 45 + struct mlx5e_ipsec_status_checks status_drops; 46 + struct mlx5e_ipsec_fc *fc; 47 + struct mlx5_fs_chains *chains; 48 + u8 allow_tunnel_mode : 1; 49 + }; 50 + 35 51 /* IPsec RX flow steering */ 36 52 static enum mlx5_traffic_types family2tt(u32 family) 37 53 { ··· 144 128 return mlx5_create_auto_grouped_flow_table(ns, &ft_attr); 145 129 } 146 130 147 - static int ipsec_status_rule(struct mlx5_core_dev *mdev, 148 - struct mlx5e_ipsec_rx *rx, 149 - struct mlx5_flow_destination *dest) 131 + static void ipsec_rx_status_drop_destroy(struct mlx5e_ipsec *ipsec, 132 + struct mlx5e_ipsec_rx *rx) 150 133 { 151 - u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {}; 134 + mlx5_del_flow_rules(rx->status_drops.all.rule); 135 + mlx5_fc_destroy(ipsec->mdev, rx->status_drops.all.fc); 136 + mlx5_destroy_flow_group(rx->status_drops.drop_all_group); 137 + } 138 + 139 + static void ipsec_rx_status_pass_destroy(struct mlx5e_ipsec *ipsec, 140 + struct mlx5e_ipsec_rx *rx) 141 + { 142 + mlx5_del_flow_rules(rx->status.rule); 143 + 144 + if (rx != ipsec->rx_esw) 145 + return; 146 + 147 + #ifdef CONFIG_MLX5_ESWITCH 148 + mlx5_chains_put_table(esw_chains(ipsec->mdev->priv.eswitch), 0, 1, 0); 149 + #endif 150 + } 151 + 152 + static int rx_add_rule_drop_auth_trailer(struct mlx5e_ipsec_sa_entry *sa_entry, 153 + struct mlx5e_ipsec_rx *rx) 154 + { 155 + struct mlx5e_ipsec *ipsec = sa_entry->ipsec; 156 + struct mlx5_flow_table *ft = rx->ft.status; 157 + struct mlx5_core_dev *mdev = ipsec->mdev; 158 + struct mlx5_flow_destination dest = {}; 152 159 struct mlx5_flow_act flow_act = {}; 153 - struct mlx5_modify_hdr *modify_hdr; 154 - struct mlx5_flow_handle *fte; 160 + struct mlx5_flow_handle *rule; 161 + struct mlx5_fc *flow_counter; 155 162 struct mlx5_flow_spec *spec; 156 163 int err; 157 164 ··· 182 143 if (!spec) 183 144 return -ENOMEM; 184 145 185 - /* Action to copy 7 bit ipsec_syndrome to regB[24:30] */ 186 - MLX5_SET(copy_action_in, action, action_type, MLX5_ACTION_TYPE_COPY); 187 - MLX5_SET(copy_action_in, action, src_field, MLX5_ACTION_IN_FIELD_IPSEC_SYNDROME); 188 - MLX5_SET(copy_action_in, action, src_offset, 0); 189 - MLX5_SET(copy_action_in, action, length, 7); 190 - MLX5_SET(copy_action_in, action, dst_field, MLX5_ACTION_IN_FIELD_METADATA_REG_B); 191 - MLX5_SET(copy_action_in, action, dst_offset, 24); 192 - 193 - modify_hdr = mlx5_modify_header_alloc(mdev, MLX5_FLOW_NAMESPACE_KERNEL, 194 - 1, action); 195 - 196 - if (IS_ERR(modify_hdr)) { 197 - err = PTR_ERR(modify_hdr); 146 + flow_counter = mlx5_fc_create(mdev, true); 147 + if (IS_ERR(flow_counter)) { 148 + err = PTR_ERR(flow_counter); 198 149 mlx5_core_err(mdev, 199 - "fail to alloc ipsec copy modify_header_id err=%d\n", err); 200 - goto out_spec; 150 + "Failed to add ipsec rx status drop rule counter, err=%d\n", err); 151 + goto err_cnt; 201 152 } 153 + sa_entry->ipsec_rule.auth.fc = flow_counter; 202 154 203 - /* create fte */ 204 - flow_act.action = MLX5_FLOW_CONTEXT_ACTION_MOD_HDR | 205 - MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | 206 - MLX5_FLOW_CONTEXT_ACTION_COUNT; 207 - flow_act.modify_hdr = modify_hdr; 208 - fte = mlx5_add_flow_rules(rx->ft.status, spec, &flow_act, dest, 2); 209 - if (IS_ERR(fte)) { 210 - err = PTR_ERR(fte); 211 - mlx5_core_err(mdev, "fail to add ipsec rx err copy rule err=%d\n", err); 212 - goto out; 155 + flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT; 156 + flow_act.flags = FLOW_ACT_NO_APPEND; 157 + dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; 158 + dest.counter_id = mlx5_fc_id(flow_counter); 159 + if (rx == ipsec->rx_esw) 160 + spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 161 + 162 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, misc_parameters_2.ipsec_syndrome); 163 + MLX5_SET(fte_match_param, spec->match_value, misc_parameters_2.ipsec_syndrome, 1); 164 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, misc_parameters_2.metadata_reg_c_2); 165 + MLX5_SET(fte_match_param, spec->match_value, 166 + misc_parameters_2.metadata_reg_c_2, 167 + sa_entry->ipsec_obj_id | BIT(31)); 168 + spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS_2; 169 + rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); 170 + if (IS_ERR(rule)) { 171 + err = PTR_ERR(rule); 172 + mlx5_core_err(mdev, 173 + "Failed to add ipsec rx status drop rule, err=%d\n", err); 174 + goto err_rule; 213 175 } 176 + sa_entry->ipsec_rule.auth.rule = rule; 177 + 178 + flow_counter = mlx5_fc_create(mdev, true); 179 + if (IS_ERR(flow_counter)) { 180 + err = PTR_ERR(flow_counter); 181 + mlx5_core_err(mdev, 182 + "Failed to add ipsec rx status drop rule counter, err=%d\n", err); 183 + goto err_cnt_2; 184 + } 185 + sa_entry->ipsec_rule.trailer.fc = flow_counter; 186 + 187 + dest.counter_id = mlx5_fc_id(flow_counter); 188 + MLX5_SET(fte_match_param, spec->match_value, misc_parameters_2.ipsec_syndrome, 2); 189 + rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); 190 + if (IS_ERR(rule)) { 191 + err = PTR_ERR(rule); 192 + mlx5_core_err(mdev, 193 + "Failed to add ipsec rx status drop rule, err=%d\n", err); 194 + goto err_rule_2; 195 + } 196 + sa_entry->ipsec_rule.trailer.rule = rule; 214 197 215 198 kvfree(spec); 216 - rx->status.rule = fte; 217 - rx->status.modify_hdr = modify_hdr; 218 199 return 0; 219 200 220 - out: 221 - mlx5_modify_header_dealloc(mdev, modify_hdr); 222 - out_spec: 201 + err_rule_2: 202 + mlx5_fc_destroy(mdev, sa_entry->ipsec_rule.trailer.fc); 203 + err_cnt_2: 204 + mlx5_del_flow_rules(sa_entry->ipsec_rule.auth.rule); 205 + err_rule: 206 + mlx5_fc_destroy(mdev, sa_entry->ipsec_rule.auth.fc); 207 + err_cnt: 223 208 kvfree(spec); 209 + return err; 210 + } 211 + 212 + static int rx_add_rule_drop_replay(struct mlx5e_ipsec_sa_entry *sa_entry, struct mlx5e_ipsec_rx *rx) 213 + { 214 + struct mlx5e_ipsec *ipsec = sa_entry->ipsec; 215 + struct mlx5_flow_table *ft = rx->ft.status; 216 + struct mlx5_core_dev *mdev = ipsec->mdev; 217 + struct mlx5_flow_destination dest = {}; 218 + struct mlx5_flow_act flow_act = {}; 219 + struct mlx5_flow_handle *rule; 220 + struct mlx5_fc *flow_counter; 221 + struct mlx5_flow_spec *spec; 222 + int err; 223 + 224 + spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 225 + if (!spec) 226 + return -ENOMEM; 227 + 228 + flow_counter = mlx5_fc_create(mdev, true); 229 + if (IS_ERR(flow_counter)) { 230 + err = PTR_ERR(flow_counter); 231 + mlx5_core_err(mdev, 232 + "Failed to add ipsec rx status drop rule counter, err=%d\n", err); 233 + goto err_cnt; 234 + } 235 + 236 + flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT; 237 + flow_act.flags = FLOW_ACT_NO_APPEND; 238 + dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; 239 + dest.counter_id = mlx5_fc_id(flow_counter); 240 + if (rx == ipsec->rx_esw) 241 + spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 242 + 243 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, misc_parameters_2.metadata_reg_c_4); 244 + MLX5_SET(fte_match_param, spec->match_value, misc_parameters_2.metadata_reg_c_4, 1); 245 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, misc_parameters_2.metadata_reg_c_2); 246 + MLX5_SET(fte_match_param, spec->match_value, misc_parameters_2.metadata_reg_c_2, 247 + sa_entry->ipsec_obj_id | BIT(31)); 248 + spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS_2; 249 + rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); 250 + if (IS_ERR(rule)) { 251 + err = PTR_ERR(rule); 252 + mlx5_core_err(mdev, 253 + "Failed to add ipsec rx status drop rule, err=%d\n", err); 254 + goto err_rule; 255 + } 256 + 257 + sa_entry->ipsec_rule.replay.rule = rule; 258 + sa_entry->ipsec_rule.replay.fc = flow_counter; 259 + 260 + kvfree(spec); 261 + return 0; 262 + 263 + err_rule: 264 + mlx5_fc_destroy(mdev, flow_counter); 265 + err_cnt: 266 + kvfree(spec); 267 + return err; 268 + } 269 + 270 + static int ipsec_rx_status_drop_all_create(struct mlx5e_ipsec *ipsec, 271 + struct mlx5e_ipsec_rx *rx) 272 + { 273 + int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 274 + struct mlx5_flow_table *ft = rx->ft.status; 275 + struct mlx5_core_dev *mdev = ipsec->mdev; 276 + struct mlx5_flow_destination dest = {}; 277 + struct mlx5_flow_act flow_act = {}; 278 + struct mlx5_flow_handle *rule; 279 + struct mlx5_fc *flow_counter; 280 + struct mlx5_flow_spec *spec; 281 + struct mlx5_flow_group *g; 282 + u32 *flow_group_in; 283 + int err = 0; 284 + 285 + flow_group_in = kvzalloc(inlen, GFP_KERNEL); 286 + spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 287 + if (!flow_group_in || !spec) { 288 + err = -ENOMEM; 289 + goto err_out; 290 + } 291 + 292 + MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, ft->max_fte - 1); 293 + MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, ft->max_fte - 1); 294 + g = mlx5_create_flow_group(ft, flow_group_in); 295 + if (IS_ERR(g)) { 296 + err = PTR_ERR(g); 297 + mlx5_core_err(mdev, 298 + "Failed to add ipsec rx status drop flow group, err=%d\n", err); 299 + goto err_out; 300 + } 301 + 302 + flow_counter = mlx5_fc_create(mdev, false); 303 + if (IS_ERR(flow_counter)) { 304 + err = PTR_ERR(flow_counter); 305 + mlx5_core_err(mdev, 306 + "Failed to add ipsec rx status drop rule counter, err=%d\n", err); 307 + goto err_cnt; 308 + } 309 + 310 + flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT; 311 + dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; 312 + dest.counter_id = mlx5_fc_id(flow_counter); 313 + if (rx == ipsec->rx_esw) 314 + spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 315 + rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); 316 + if (IS_ERR(rule)) { 317 + err = PTR_ERR(rule); 318 + mlx5_core_err(mdev, 319 + "Failed to add ipsec rx status drop rule, err=%d\n", err); 320 + goto err_rule; 321 + } 322 + 323 + rx->status_drops.drop_all_group = g; 324 + rx->status_drops.all.rule = rule; 325 + rx->status_drops.all.fc = flow_counter; 326 + 327 + kvfree(flow_group_in); 328 + kvfree(spec); 329 + return 0; 330 + 331 + err_rule: 332 + mlx5_fc_destroy(mdev, flow_counter); 333 + err_cnt: 334 + mlx5_destroy_flow_group(g); 335 + err_out: 336 + kvfree(flow_group_in); 337 + kvfree(spec); 338 + return err; 339 + } 340 + 341 + static int ipsec_rx_status_pass_create(struct mlx5e_ipsec *ipsec, 342 + struct mlx5e_ipsec_rx *rx, 343 + struct mlx5_flow_destination *dest) 344 + { 345 + struct mlx5_flow_act flow_act = {}; 346 + struct mlx5_flow_handle *rule; 347 + struct mlx5_flow_spec *spec; 348 + int err; 349 + 350 + spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 351 + if (!spec) 352 + return -ENOMEM; 353 + 354 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 355 + misc_parameters_2.ipsec_syndrome); 356 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 357 + misc_parameters_2.metadata_reg_c_4); 358 + MLX5_SET(fte_match_param, spec->match_value, 359 + misc_parameters_2.ipsec_syndrome, 0); 360 + MLX5_SET(fte_match_param, spec->match_value, 361 + misc_parameters_2.metadata_reg_c_4, 0); 362 + if (rx == ipsec->rx_esw) 363 + spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 364 + spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS_2; 365 + flow_act.flags = FLOW_ACT_NO_APPEND; 366 + flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | 367 + MLX5_FLOW_CONTEXT_ACTION_COUNT; 368 + rule = mlx5_add_flow_rules(rx->ft.status, spec, &flow_act, dest, 2); 369 + if (IS_ERR(rule)) { 370 + err = PTR_ERR(rule); 371 + mlx5_core_warn(ipsec->mdev, 372 + "Failed to add ipsec rx status pass rule, err=%d\n", err); 373 + goto err_rule; 374 + } 375 + 376 + rx->status.rule = rule; 377 + kvfree(spec); 378 + return 0; 379 + 380 + err_rule: 381 + kvfree(spec); 382 + return err; 383 + } 384 + 385 + static void mlx5_ipsec_rx_status_destroy(struct mlx5e_ipsec *ipsec, 386 + struct mlx5e_ipsec_rx *rx) 387 + { 388 + ipsec_rx_status_pass_destroy(ipsec, rx); 389 + ipsec_rx_status_drop_destroy(ipsec, rx); 390 + } 391 + 392 + static int mlx5_ipsec_rx_status_create(struct mlx5e_ipsec *ipsec, 393 + struct mlx5e_ipsec_rx *rx, 394 + struct mlx5_flow_destination *dest) 395 + { 396 + int err; 397 + 398 + err = ipsec_rx_status_drop_all_create(ipsec, rx); 399 + if (err) 400 + return err; 401 + 402 + err = ipsec_rx_status_pass_create(ipsec, rx, dest); 403 + if (err) 404 + goto err_pass_create; 405 + 406 + return 0; 407 + 408 + err_pass_create: 409 + ipsec_rx_status_drop_destroy(ipsec, rx); 224 410 return err; 225 411 } 226 412 ··· 597 333 mlx5_destroy_flow_table(rx->ft.sa); 598 334 if (rx->allow_tunnel_mode) 599 335 mlx5_eswitch_unblock_encap(mdev); 600 - if (rx == ipsec->rx_esw) { 601 - mlx5_esw_ipsec_rx_status_destroy(ipsec, rx); 602 - } else { 603 - mlx5_del_flow_rules(rx->status.rule); 604 - mlx5_modify_header_dealloc(mdev, rx->status.modify_hdr); 605 - } 336 + mlx5_ipsec_rx_status_destroy(ipsec, rx); 606 337 mlx5_destroy_flow_table(rx->ft.status); 607 338 608 339 mlx5_ipsec_fs_roce_rx_destroy(ipsec->roce, family, mdev); ··· 678 419 if (err) 679 420 return err; 680 421 681 - ft = ipsec_ft_create(attr.ns, attr.status_level, attr.prio, 1, 0); 422 + ft = ipsec_ft_create(attr.ns, attr.status_level, attr.prio, 3, 0); 682 423 if (IS_ERR(ft)) { 683 424 err = PTR_ERR(ft); 684 425 goto err_fs_ft_status; ··· 687 428 688 429 dest[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; 689 430 dest[1].counter_id = mlx5_fc_id(rx->fc->cnt); 690 - if (rx == ipsec->rx_esw) 691 - err = mlx5_esw_ipsec_rx_status_create(ipsec, rx, dest); 692 - else 693 - err = ipsec_status_rule(mdev, rx, dest); 431 + err = mlx5_ipsec_rx_status_create(ipsec, rx, dest); 694 432 if (err) 695 433 goto err_add; 696 434 ··· 1212 956 MLX5_SET(fte_match_param, spec->match_value, outer_headers.ip_protocol, IPPROTO_ESP); 1213 957 } 1214 958 1215 - static void setup_fte_spi(struct mlx5_flow_spec *spec, u32 spi) 959 + static void setup_fte_spi(struct mlx5_flow_spec *spec, u32 spi, bool encap) 1216 960 { 1217 961 /* SPI number */ 1218 962 spec->match_criteria_enable |= MLX5_MATCH_MISC_PARAMETERS; 1219 963 1220 - MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, misc_parameters.outer_esp_spi); 1221 - MLX5_SET(fte_match_param, spec->match_value, misc_parameters.outer_esp_spi, spi); 964 + if (encap) { 965 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 966 + misc_parameters.inner_esp_spi); 967 + MLX5_SET(fte_match_param, spec->match_value, 968 + misc_parameters.inner_esp_spi, spi); 969 + } else { 970 + MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 971 + misc_parameters.outer_esp_spi); 972 + MLX5_SET(fte_match_param, spec->match_value, 973 + misc_parameters.outer_esp_spi, spi); 974 + } 1222 975 } 1223 976 1224 977 static void setup_fte_no_frags(struct mlx5_flow_spec *spec) ··· 1317 1052 struct mlx5_flow_act *flow_act) 1318 1053 { 1319 1054 enum mlx5_flow_namespace_type ns_type = ipsec_fs_get_ns(ipsec, type, dir); 1320 - u8 action[MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {}; 1055 + u8 action[3][MLX5_UN_SZ_BYTES(set_add_copy_action_in_auto)] = {}; 1321 1056 struct mlx5_core_dev *mdev = ipsec->mdev; 1322 1057 struct mlx5_modify_hdr *modify_hdr; 1058 + u8 num_of_actions = 1; 1323 1059 1324 - MLX5_SET(set_action_in, action, action_type, MLX5_ACTION_TYPE_SET); 1060 + MLX5_SET(set_action_in, action[0], action_type, MLX5_ACTION_TYPE_SET); 1325 1061 switch (dir) { 1326 1062 case XFRM_DEV_OFFLOAD_IN: 1327 - MLX5_SET(set_action_in, action, field, 1063 + MLX5_SET(set_action_in, action[0], field, 1328 1064 MLX5_ACTION_IN_FIELD_METADATA_REG_B); 1065 + 1066 + num_of_actions++; 1067 + MLX5_SET(set_action_in, action[1], action_type, MLX5_ACTION_TYPE_SET); 1068 + MLX5_SET(set_action_in, action[1], field, MLX5_ACTION_IN_FIELD_METADATA_REG_C_2); 1069 + MLX5_SET(set_action_in, action[1], data, val); 1070 + MLX5_SET(set_action_in, action[1], offset, 0); 1071 + MLX5_SET(set_action_in, action[1], length, 32); 1072 + 1073 + if (type == XFRM_DEV_OFFLOAD_CRYPTO) { 1074 + num_of_actions++; 1075 + MLX5_SET(set_action_in, action[2], action_type, 1076 + MLX5_ACTION_TYPE_SET); 1077 + MLX5_SET(set_action_in, action[2], field, 1078 + MLX5_ACTION_IN_FIELD_METADATA_REG_C_4); 1079 + MLX5_SET(set_action_in, action[2], data, 0); 1080 + MLX5_SET(set_action_in, action[2], offset, 0); 1081 + MLX5_SET(set_action_in, action[2], length, 32); 1082 + } 1329 1083 break; 1330 1084 case XFRM_DEV_OFFLOAD_OUT: 1331 - MLX5_SET(set_action_in, action, field, 1085 + MLX5_SET(set_action_in, action[0], field, 1332 1086 MLX5_ACTION_IN_FIELD_METADATA_REG_C_4); 1333 1087 break; 1334 1088 default: 1335 1089 return -EINVAL; 1336 1090 } 1337 1091 1338 - MLX5_SET(set_action_in, action, data, val); 1339 - MLX5_SET(set_action_in, action, offset, 0); 1340 - MLX5_SET(set_action_in, action, length, 32); 1092 + MLX5_SET(set_action_in, action[0], data, val); 1093 + MLX5_SET(set_action_in, action[0], offset, 0); 1094 + MLX5_SET(set_action_in, action[0], length, 32); 1341 1095 1342 - modify_hdr = mlx5_modify_header_alloc(mdev, ns_type, 1, action); 1096 + modify_hdr = mlx5_modify_header_alloc(mdev, ns_type, num_of_actions, action); 1343 1097 if (IS_ERR(modify_hdr)) { 1344 1098 mlx5_core_err(mdev, "Failed to allocate modify_header %ld\n", 1345 1099 PTR_ERR(modify_hdr)); ··· 1605 1321 else 1606 1322 setup_fte_addr6(spec, attrs->saddr.a6, attrs->daddr.a6); 1607 1323 1608 - setup_fte_spi(spec, attrs->spi); 1609 - setup_fte_esp(spec); 1324 + setup_fte_spi(spec, attrs->spi, attrs->encap); 1325 + if (!attrs->encap) 1326 + setup_fte_esp(spec); 1610 1327 setup_fte_no_frags(spec); 1611 1328 setup_fte_upper_proto_match(spec, &attrs->upspec); 1612 1329 ··· 1657 1372 mlx5_core_err(mdev, "fail to add RX ipsec rule err=%d\n", err); 1658 1373 goto err_add_flow; 1659 1374 } 1375 + if (attrs->type == XFRM_DEV_OFFLOAD_PACKET) 1376 + err = rx_add_rule_drop_replay(sa_entry, rx); 1377 + if (err) 1378 + goto err_add_replay; 1379 + 1380 + err = rx_add_rule_drop_auth_trailer(sa_entry, rx); 1381 + if (err) 1382 + goto err_drop_reason; 1383 + 1660 1384 kvfree(spec); 1661 1385 1662 1386 sa_entry->ipsec_rule.rule = rule; ··· 1674 1380 sa_entry->ipsec_rule.pkt_reformat = flow_act.pkt_reformat; 1675 1381 return 0; 1676 1382 1383 + err_drop_reason: 1384 + if (sa_entry->ipsec_rule.replay.rule) { 1385 + mlx5_del_flow_rules(sa_entry->ipsec_rule.replay.rule); 1386 + mlx5_fc_destroy(mdev, sa_entry->ipsec_rule.replay.fc); 1387 + } 1388 + err_add_replay: 1389 + mlx5_del_flow_rules(rule); 1677 1390 err_add_flow: 1678 1391 mlx5_fc_destroy(mdev, counter); 1679 1392 err_add_cnt: ··· 1729 1428 1730 1429 switch (attrs->type) { 1731 1430 case XFRM_DEV_OFFLOAD_CRYPTO: 1732 - setup_fte_spi(spec, attrs->spi); 1431 + setup_fte_spi(spec, attrs->spi, false); 1733 1432 setup_fte_esp(spec); 1734 1433 setup_fte_reg_a(spec); 1735 1434 break; ··· 2110 1809 struct mlx5_eswitch *esw = mdev->priv.eswitch; 2111 1810 int err = 0; 2112 1811 2113 - if (esw) 2114 - down_write(&esw->mode_lock); 1812 + if (esw) { 1813 + err = mlx5_esw_lock(esw); 1814 + if (err) 1815 + return err; 1816 + } 2115 1817 2116 1818 if (mdev->num_block_ipsec) { 2117 1819 err = -EBUSY; ··· 2125 1821 2126 1822 unlock: 2127 1823 if (esw) 2128 - up_write(&esw->mode_lock); 1824 + mlx5_esw_unlock(esw); 2129 1825 2130 1826 return err; 2131 1827 } ··· 2191 1887 2192 1888 if (ipsec_rule->modify_hdr) 2193 1889 mlx5_modify_header_dealloc(mdev, ipsec_rule->modify_hdr); 1890 + 1891 + mlx5_del_flow_rules(ipsec_rule->trailer.rule); 1892 + mlx5_fc_destroy(mdev, ipsec_rule->trailer.fc); 1893 + 1894 + mlx5_del_flow_rules(ipsec_rule->auth.rule); 1895 + mlx5_fc_destroy(mdev, ipsec_rule->auth.fc); 1896 + 1897 + if (ipsec_rule->replay.rule) { 1898 + mlx5_del_flow_rules(ipsec_rule->replay.rule); 1899 + mlx5_fc_destroy(mdev, ipsec_rule->replay.fc); 1900 + } 2194 1901 mlx5_esw_ipsec_rx_id_mapping_remove(sa_entry); 2195 1902 rx_ft_put(sa_entry->ipsec, sa_entry->attrs.family, sa_entry->attrs.type); 2196 1903 } ··· 2272 1957 kfree(ipsec->rx_ipv6); 2273 1958 2274 1959 if (ipsec->is_uplink_rep) { 2275 - xa_destroy(&ipsec->rx_esw->ipsec_obj_id_map); 1960 + xa_destroy(&ipsec->ipsec_obj_id_map); 2276 1961 2277 1962 mutex_destroy(&ipsec->tx_esw->ft.mutex); 2278 1963 WARN_ON(ipsec->tx_esw->ft.refcnt); ··· 2335 2020 mutex_init(&ipsec->tx_esw->ft.mutex); 2336 2021 mutex_init(&ipsec->rx_esw->ft.mutex); 2337 2022 ipsec->tx_esw->ns = ns_esw; 2338 - xa_init_flags(&ipsec->rx_esw->ipsec_obj_id_map, XA_FLAGS_ALLOC1); 2023 + xa_init_flags(&ipsec->ipsec_obj_id_map, XA_FLAGS_ALLOC1); 2339 2024 } else if (mlx5_ipsec_device_caps(mdev) & MLX5_IPSEC_CAP_ROCE) { 2340 2025 ipsec->roce = mlx5_ipsec_fs_roce_init(mdev, devcom); 2341 2026 } else {
+8 -2
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_offload.c
··· 6 6 #include "ipsec.h" 7 7 #include "lib/crypto.h" 8 8 #include "lib/ipsec_fs_roce.h" 9 + #include "fs_core.h" 10 + #include "eswitch.h" 9 11 10 12 enum { 11 13 MLX5_IPSEC_ASO_REMOVE_FLOW_PKT_CNT_OFFSET, ··· 40 38 MLX5_CAP_ETH(mdev, insert_trailer) && MLX5_CAP_ETH(mdev, swp)) 41 39 caps |= MLX5_IPSEC_CAP_CRYPTO; 42 40 43 - if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload)) { 41 + if (MLX5_CAP_IPSEC(mdev, ipsec_full_offload) && 42 + (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_DMFS || 43 + (mdev->priv.steering->mode == MLX5_FLOW_STEERING_MODE_SMFS && 44 + is_mdev_legacy_mode(mdev)))) { 44 45 if (MLX5_CAP_FLOWTABLE_NIC_TX(mdev, 45 46 reformat_add_esp_trasport) && 46 47 MLX5_CAP_FLOWTABLE_NIC_RX(mdev, ··· 100 95 101 96 if (attrs->dir == XFRM_DEV_OFFLOAD_IN) { 102 97 MLX5_SET(ipsec_aso, aso_ctx, window_sz, 103 - attrs->replay_esn.replay_window / 64); 98 + attrs->replay_esn.replay_window); 104 99 MLX5_SET(ipsec_aso, aso_ctx, mode, 105 100 MLX5_IPSEC_ASO_REPLAY_PROTECTION); 106 101 } ··· 564 559 dma_unmap_single(pdev, aso->dma_addr, sizeof(aso->ctx), 565 560 DMA_BIDIRECTIONAL); 566 561 kfree(aso); 562 + ipsec->aso = NULL; 567 563 } 568 564 569 565 static void mlx5e_ipsec_aso_copy(struct mlx5_wqe_aso_ctrl_seg *ctrl,
+24 -3
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
··· 2731 2731 { 2732 2732 int i; 2733 2733 2734 + ASSERT_RTNL(); 2734 2735 if (chs->ptp) { 2735 2736 mlx5e_ptp_close(chs->ptp); 2736 2737 chs->ptp = NULL; ··· 3013 3012 if (mlx5e_is_vport_rep(priv)) 3014 3013 mlx5e_rep_activate_channels(priv); 3015 3014 3015 + set_bit(MLX5E_STATE_CHANNELS_ACTIVE, &priv->state); 3016 + 3016 3017 mlx5e_wait_channels_min_rx_wqes(&priv->channels); 3017 3018 3018 3019 if (priv->rx_res) 3019 3020 mlx5e_rx_res_channels_activate(priv->rx_res, &priv->channels); 3020 3021 } 3021 3022 3023 + static void mlx5e_cancel_tx_timeout_work(struct mlx5e_priv *priv) 3024 + { 3025 + WARN_ON_ONCE(test_bit(MLX5E_STATE_CHANNELS_ACTIVE, &priv->state)); 3026 + if (current_work() != &priv->tx_timeout_work) 3027 + cancel_work_sync(&priv->tx_timeout_work); 3028 + } 3029 + 3022 3030 void mlx5e_deactivate_priv_channels(struct mlx5e_priv *priv) 3023 3031 { 3024 3032 if (priv->rx_res) 3025 3033 mlx5e_rx_res_channels_deactivate(priv->rx_res); 3034 + 3035 + clear_bit(MLX5E_STATE_CHANNELS_ACTIVE, &priv->state); 3036 + mlx5e_cancel_tx_timeout_work(priv); 3026 3037 3027 3038 if (mlx5e_is_vport_rep(priv)) 3028 3039 mlx5e_rep_deactivate_channels(priv); ··· 4814 4801 struct net_device *netdev = priv->netdev; 4815 4802 int i; 4816 4803 4817 - rtnl_lock(); 4818 - mutex_lock(&priv->state_lock); 4804 + /* Take rtnl_lock to ensure no change in netdev->real_num_tx_queues 4805 + * through this flow. However, channel closing flows have to wait for 4806 + * this work to finish while holding rtnl lock too. So either get the 4807 + * lock or find that channels are being closed for other reason and 4808 + * this work is not relevant anymore. 4809 + */ 4810 + while (!rtnl_trylock()) { 4811 + if (!test_bit(MLX5E_STATE_CHANNELS_ACTIVE, &priv->state)) 4812 + return; 4813 + msleep(20); 4814 + } 4819 4815 4820 4816 if (!test_bit(MLX5E_STATE_OPENED, &priv->state)) 4821 4817 goto unlock; ··· 4843 4821 } 4844 4822 4845 4823 unlock: 4846 - mutex_unlock(&priv->state_lock); 4847 4824 rtnl_unlock(); 4848 4825 } 4849 4826
+1 -1
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
··· 1497 1497 1498 1498 dl_port = mlx5_esw_offloads_devlink_port(dev->priv.eswitch, 1499 1499 rpriv->rep->vport); 1500 - if (dl_port) { 1500 + if (!IS_ERR(dl_port)) { 1501 1501 SET_NETDEV_DEVLINK_PORT(netdev, dl_port); 1502 1502 mlx5e_rep_vnic_reporter_create(priv, dl_port); 1503 1503 }
+21 -4
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 444 444 struct mlx5e_flow_meter_handle *meter; 445 445 enum mlx5e_post_meter_type type; 446 446 447 + if (IS_ERR(post_act)) 448 + return PTR_ERR(post_act); 449 + 447 450 meter = mlx5e_tc_meter_replace(priv->mdev, &attr->meter_attr.params); 448 451 if (IS_ERR(meter)) { 449 452 mlx5_core_err(priv->mdev, "Failed to get flow meter\n"); ··· 3742 3739 } 3743 3740 3744 3741 static int 3742 + set_branch_dest_ft(struct mlx5e_priv *priv, struct mlx5_flow_attr *attr) 3743 + { 3744 + struct mlx5e_post_act *post_act = get_post_action(priv); 3745 + 3746 + if (IS_ERR(post_act)) 3747 + return PTR_ERR(post_act); 3748 + 3749 + attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; 3750 + attr->dest_ft = mlx5e_tc_post_act_get_ft(post_act); 3751 + 3752 + return 0; 3753 + } 3754 + 3755 + static int 3745 3756 alloc_branch_attr(struct mlx5e_tc_flow *flow, 3746 3757 struct mlx5e_tc_act_branch_ctrl *cond, 3747 3758 struct mlx5_flow_attr **cond_attr, ··· 3778 3761 break; 3779 3762 case FLOW_ACTION_ACCEPT: 3780 3763 case FLOW_ACTION_PIPE: 3781 - attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; 3782 - attr->dest_ft = mlx5e_tc_post_act_get_ft(get_post_action(flow->priv)); 3764 + if (set_branch_dest_ft(flow->priv, attr)) 3765 + goto out_err; 3783 3766 break; 3784 3767 case FLOW_ACTION_JUMP: 3785 3768 if (*jump_count) { ··· 3788 3771 goto out_err; 3789 3772 } 3790 3773 *jump_count = cond->extval; 3791 - attr->action |= MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; 3792 - attr->dest_ft = mlx5e_tc_post_act_get_ft(get_post_action(flow->priv)); 3774 + if (set_branch_dest_ft(flow->priv, attr)) 3775 + goto out_err; 3793 3776 break; 3794 3777 default: 3795 3778 err = -EOPNOTSUPP;
+5 -157
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.c
··· 21 21 MLX5_ESW_IPSEC_TX_ESP_FT_CNT_LEVEL, 22 22 }; 23 23 24 - static void esw_ipsec_rx_status_drop_destroy(struct mlx5e_ipsec *ipsec, 25 - struct mlx5e_ipsec_rx *rx) 26 - { 27 - mlx5_del_flow_rules(rx->status_drop.rule); 28 - mlx5_destroy_flow_group(rx->status_drop.group); 29 - mlx5_fc_destroy(ipsec->mdev, rx->status_drop_cnt); 30 - } 31 - 32 - static void esw_ipsec_rx_status_pass_destroy(struct mlx5e_ipsec *ipsec, 33 - struct mlx5e_ipsec_rx *rx) 34 - { 35 - mlx5_del_flow_rules(rx->status.rule); 36 - mlx5_chains_put_table(esw_chains(ipsec->mdev->priv.eswitch), 0, 1, 0); 37 - } 38 - 39 - static int esw_ipsec_rx_status_drop_create(struct mlx5e_ipsec *ipsec, 40 - struct mlx5e_ipsec_rx *rx) 41 - { 42 - int inlen = MLX5_ST_SZ_BYTES(create_flow_group_in); 43 - struct mlx5_flow_table *ft = rx->ft.status; 44 - struct mlx5_core_dev *mdev = ipsec->mdev; 45 - struct mlx5_flow_destination dest = {}; 46 - struct mlx5_flow_act flow_act = {}; 47 - struct mlx5_flow_handle *rule; 48 - struct mlx5_fc *flow_counter; 49 - struct mlx5_flow_spec *spec; 50 - struct mlx5_flow_group *g; 51 - u32 *flow_group_in; 52 - int err = 0; 53 - 54 - flow_group_in = kvzalloc(inlen, GFP_KERNEL); 55 - spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 56 - if (!flow_group_in || !spec) { 57 - err = -ENOMEM; 58 - goto err_out; 59 - } 60 - 61 - MLX5_SET(create_flow_group_in, flow_group_in, start_flow_index, ft->max_fte - 1); 62 - MLX5_SET(create_flow_group_in, flow_group_in, end_flow_index, ft->max_fte - 1); 63 - g = mlx5_create_flow_group(ft, flow_group_in); 64 - if (IS_ERR(g)) { 65 - err = PTR_ERR(g); 66 - mlx5_core_err(mdev, 67 - "Failed to add ipsec rx status drop flow group, err=%d\n", err); 68 - goto err_out; 69 - } 70 - 71 - flow_counter = mlx5_fc_create(mdev, false); 72 - if (IS_ERR(flow_counter)) { 73 - err = PTR_ERR(flow_counter); 74 - mlx5_core_err(mdev, 75 - "Failed to add ipsec rx status drop rule counter, err=%d\n", err); 76 - goto err_cnt; 77 - } 78 - 79 - flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP | MLX5_FLOW_CONTEXT_ACTION_COUNT; 80 - dest.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; 81 - dest.counter_id = mlx5_fc_id(flow_counter); 82 - spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 83 - rule = mlx5_add_flow_rules(ft, spec, &flow_act, &dest, 1); 84 - if (IS_ERR(rule)) { 85 - err = PTR_ERR(rule); 86 - mlx5_core_err(mdev, 87 - "Failed to add ipsec rx status drop rule, err=%d\n", err); 88 - goto err_rule; 89 - } 90 - 91 - rx->status_drop.group = g; 92 - rx->status_drop.rule = rule; 93 - rx->status_drop_cnt = flow_counter; 94 - 95 - kvfree(flow_group_in); 96 - kvfree(spec); 97 - return 0; 98 - 99 - err_rule: 100 - mlx5_fc_destroy(mdev, flow_counter); 101 - err_cnt: 102 - mlx5_destroy_flow_group(g); 103 - err_out: 104 - kvfree(flow_group_in); 105 - kvfree(spec); 106 - return err; 107 - } 108 - 109 - static int esw_ipsec_rx_status_pass_create(struct mlx5e_ipsec *ipsec, 110 - struct mlx5e_ipsec_rx *rx, 111 - struct mlx5_flow_destination *dest) 112 - { 113 - struct mlx5_flow_act flow_act = {}; 114 - struct mlx5_flow_handle *rule; 115 - struct mlx5_flow_spec *spec; 116 - int err; 117 - 118 - spec = kvzalloc(sizeof(*spec), GFP_KERNEL); 119 - if (!spec) 120 - return -ENOMEM; 121 - 122 - MLX5_SET_TO_ONES(fte_match_param, spec->match_criteria, 123 - misc_parameters_2.ipsec_syndrome); 124 - MLX5_SET(fte_match_param, spec->match_value, 125 - misc_parameters_2.ipsec_syndrome, 0); 126 - spec->flow_context.flow_source = MLX5_FLOW_CONTEXT_FLOW_SOURCE_UPLINK; 127 - spec->match_criteria_enable = MLX5_MATCH_MISC_PARAMETERS_2; 128 - flow_act.flags = FLOW_ACT_NO_APPEND; 129 - flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST | 130 - MLX5_FLOW_CONTEXT_ACTION_COUNT; 131 - rule = mlx5_add_flow_rules(rx->ft.status, spec, &flow_act, dest, 2); 132 - if (IS_ERR(rule)) { 133 - err = PTR_ERR(rule); 134 - mlx5_core_warn(ipsec->mdev, 135 - "Failed to add ipsec rx status pass rule, err=%d\n", err); 136 - goto err_rule; 137 - } 138 - 139 - rx->status.rule = rule; 140 - kvfree(spec); 141 - return 0; 142 - 143 - err_rule: 144 - kvfree(spec); 145 - return err; 146 - } 147 - 148 - void mlx5_esw_ipsec_rx_status_destroy(struct mlx5e_ipsec *ipsec, 149 - struct mlx5e_ipsec_rx *rx) 150 - { 151 - esw_ipsec_rx_status_pass_destroy(ipsec, rx); 152 - esw_ipsec_rx_status_drop_destroy(ipsec, rx); 153 - } 154 - 155 - int mlx5_esw_ipsec_rx_status_create(struct mlx5e_ipsec *ipsec, 156 - struct mlx5e_ipsec_rx *rx, 157 - struct mlx5_flow_destination *dest) 158 - { 159 - int err; 160 - 161 - err = esw_ipsec_rx_status_drop_create(ipsec, rx); 162 - if (err) 163 - return err; 164 - 165 - err = esw_ipsec_rx_status_pass_create(ipsec, rx, dest); 166 - if (err) 167 - goto err_pass_create; 168 - 169 - return 0; 170 - 171 - err_pass_create: 172 - esw_ipsec_rx_status_drop_destroy(ipsec, rx); 173 - return err; 174 - } 175 - 176 24 void mlx5_esw_ipsec_rx_create_attr_set(struct mlx5e_ipsec *ipsec, 177 25 struct mlx5e_ipsec_rx_create_attr *attr) 178 26 { ··· 50 202 u32 mapped_id; 51 203 int err; 52 204 53 - err = xa_alloc_bh(&ipsec->rx_esw->ipsec_obj_id_map, &mapped_id, 205 + err = xa_alloc_bh(&ipsec->ipsec_obj_id_map, &mapped_id, 54 206 xa_mk_value(sa_entry->ipsec_obj_id), 55 207 XA_LIMIT(1, ESW_IPSEC_RX_MAPPED_ID_MASK), 0); 56 208 if (err) ··· 81 233 return 0; 82 234 83 235 err_header_alloc: 84 - xa_erase_bh(&ipsec->rx_esw->ipsec_obj_id_map, mapped_id); 236 + xa_erase_bh(&ipsec->ipsec_obj_id_map, mapped_id); 85 237 return err; 86 238 } 87 239 ··· 90 242 struct mlx5e_ipsec *ipsec = sa_entry->ipsec; 91 243 92 244 if (sa_entry->rx_mapped_id) 93 - xa_erase_bh(&ipsec->rx_esw->ipsec_obj_id_map, 245 + xa_erase_bh(&ipsec->ipsec_obj_id_map, 94 246 sa_entry->rx_mapped_id); 95 247 } 96 248 ··· 100 252 struct mlx5e_ipsec *ipsec = priv->ipsec; 101 253 void *val; 102 254 103 - val = xa_load(&ipsec->rx_esw->ipsec_obj_id_map, id); 255 + val = xa_load(&ipsec->ipsec_obj_id_map, id); 104 256 if (!val) 105 257 return -ENOENT; 106 258 ··· 152 304 153 305 xa_for_each(&esw->offloads.vport_reps, i, rep) { 154 306 rpriv = rep->rep_data[REP_ETH].priv; 155 - if (!rpriv || !rpriv->netdev) 307 + if (!rpriv || !rpriv->netdev || !atomic_read(&rpriv->tc_ht.nelems)) 156 308 continue; 157 309 158 310 rhashtable_walk_enter(&rpriv->tc_ht, &iter);
-15
drivers/net/ethernet/mellanox/mlx5/core/esw/ipsec_fs.h
··· 8 8 struct mlx5e_ipsec_sa_entry; 9 9 10 10 #ifdef CONFIG_MLX5_ESWITCH 11 - void mlx5_esw_ipsec_rx_status_destroy(struct mlx5e_ipsec *ipsec, 12 - struct mlx5e_ipsec_rx *rx); 13 - int mlx5_esw_ipsec_rx_status_create(struct mlx5e_ipsec *ipsec, 14 - struct mlx5e_ipsec_rx *rx, 15 - struct mlx5_flow_destination *dest); 16 11 void mlx5_esw_ipsec_rx_create_attr_set(struct mlx5e_ipsec *ipsec, 17 12 struct mlx5e_ipsec_rx_create_attr *attr); 18 13 int mlx5_esw_ipsec_rx_status_pass_dest_get(struct mlx5e_ipsec *ipsec, ··· 21 26 struct mlx5e_ipsec_tx_create_attr *attr); 22 27 void mlx5_esw_ipsec_restore_dest_uplink(struct mlx5_core_dev *mdev); 23 28 #else 24 - static inline void mlx5_esw_ipsec_rx_status_destroy(struct mlx5e_ipsec *ipsec, 25 - struct mlx5e_ipsec_rx *rx) {} 26 - 27 - static inline int mlx5_esw_ipsec_rx_status_create(struct mlx5e_ipsec *ipsec, 28 - struct mlx5e_ipsec_rx *rx, 29 - struct mlx5_flow_destination *dest) 30 - { 31 - return -EINVAL; 32 - } 33 - 34 29 static inline void mlx5_esw_ipsec_rx_create_attr_set(struct mlx5e_ipsec *ipsec, 35 30 struct mlx5e_ipsec_rx_create_attr *attr) {} 36 31
+22 -13
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 1463 1463 { 1464 1464 int err; 1465 1465 1466 - lockdep_assert_held(&esw->mode_lock); 1466 + devl_assert_locked(priv_to_devlink(esw->dev)); 1467 1467 1468 1468 if (!MLX5_CAP_ESW_FLOWTABLE_FDB(esw->dev, ft_support)) { 1469 1469 esw_warn(esw->dev, "FDB is not supported, aborting ...\n"); ··· 1531 1531 if (toggle_lag) 1532 1532 mlx5_lag_disable_change(esw->dev); 1533 1533 1534 - down_write(&esw->mode_lock); 1535 1534 if (!mlx5_esw_is_fdb_created(esw)) { 1536 1535 ret = mlx5_eswitch_enable_locked(esw, num_vfs); 1537 1536 } else { ··· 1553 1554 } 1554 1555 } 1555 1556 1556 - up_write(&esw->mode_lock); 1557 - 1558 1557 if (toggle_lag) 1559 1558 mlx5_lag_enable_change(esw->dev); 1560 1559 ··· 1566 1569 return; 1567 1570 1568 1571 devl_assert_locked(priv_to_devlink(esw->dev)); 1569 - down_write(&esw->mode_lock); 1570 1572 /* If driver is unloaded, this function is called twice by remove_one() 1571 1573 * and mlx5_unload(). Prevent the second call. 1572 1574 */ 1573 1575 if (!esw->esw_funcs.num_vfs && !esw->esw_funcs.num_ec_vfs && !clear_vf) 1574 - goto unlock; 1576 + return; 1575 1577 1576 1578 esw_info(esw->dev, "Unload vfs: mode(%s), nvfs(%d), necvfs(%d), active vports(%d)\n", 1577 1579 esw->mode == MLX5_ESWITCH_LEGACY ? "LEGACY" : "OFFLOADS", ··· 1599 1603 esw->esw_funcs.num_vfs = 0; 1600 1604 else 1601 1605 esw->esw_funcs.num_ec_vfs = 0; 1602 - 1603 - unlock: 1604 - up_write(&esw->mode_lock); 1605 1606 } 1606 1607 1607 1608 /* Free resources for corresponding eswitch mode. It is called by devlink ··· 1640 1647 1641 1648 devl_assert_locked(priv_to_devlink(esw->dev)); 1642 1649 mlx5_lag_disable_change(esw->dev); 1643 - down_write(&esw->mode_lock); 1644 1650 mlx5_eswitch_disable_locked(esw); 1645 1651 esw->mode = MLX5_ESWITCH_LEGACY; 1646 - up_write(&esw->mode_lock); 1647 1652 mlx5_lag_enable_change(esw->dev); 1648 1653 } 1649 1654 ··· 2245 2254 if (!mlx5_esw_allowed(esw)) 2246 2255 return true; 2247 2256 2248 - if (down_read_trylock(&esw->mode_lock) != 0) 2257 + if (down_read_trylock(&esw->mode_lock) != 0) { 2258 + if (esw->eswitch_operation_in_progress) { 2259 + up_read(&esw->mode_lock); 2260 + return false; 2261 + } 2249 2262 return true; 2263 + } 2250 2264 2251 2265 return false; 2252 2266 } ··· 2308 2312 if (down_write_trylock(&esw->mode_lock) == 0) 2309 2313 return -EINVAL; 2310 2314 2311 - if (atomic64_read(&esw->user_count) > 0) { 2315 + if (esw->eswitch_operation_in_progress || 2316 + atomic64_read(&esw->user_count) > 0) { 2312 2317 up_write(&esw->mode_lock); 2313 2318 return -EBUSY; 2314 2319 } 2315 2320 2316 2321 return esw->mode; 2322 + } 2323 + 2324 + int mlx5_esw_lock(struct mlx5_eswitch *esw) 2325 + { 2326 + down_write(&esw->mode_lock); 2327 + 2328 + if (esw->eswitch_operation_in_progress) { 2329 + up_write(&esw->mode_lock); 2330 + return -EBUSY; 2331 + } 2332 + 2333 + return 0; 2317 2334 } 2318 2335 2319 2336 /**
+2
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 383 383 struct xarray paired; 384 384 struct mlx5_devcom_comp_dev *devcom; 385 385 u16 enabled_ipsec_vf_count; 386 + bool eswitch_operation_in_progress; 386 387 }; 387 388 388 389 void esw_offloads_disable(struct mlx5_eswitch *esw); ··· 828 827 void mlx5_esw_get(struct mlx5_core_dev *dev); 829 828 void mlx5_esw_put(struct mlx5_core_dev *dev); 830 829 int mlx5_esw_try_lock(struct mlx5_eswitch *esw); 830 + int mlx5_esw_lock(struct mlx5_eswitch *esw); 831 831 void mlx5_esw_unlock(struct mlx5_eswitch *esw); 832 832 833 833 void esw_vport_change_handle_locked(struct mlx5_vport *vport);
+33 -23
drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
··· 3653 3653 3654 3654 static bool esw_offloads_devlink_ns_eq_netdev_ns(struct devlink *devlink) 3655 3655 { 3656 + struct mlx5_core_dev *dev = devlink_priv(devlink); 3656 3657 struct net *devl_net, *netdev_net; 3657 - struct mlx5_eswitch *esw; 3658 + bool ret = false; 3658 3659 3659 - esw = mlx5_devlink_eswitch_nocheck_get(devlink); 3660 - netdev_net = dev_net(esw->dev->mlx5e_res.uplink_netdev); 3661 - devl_net = devlink_net(devlink); 3662 - 3663 - return net_eq(devl_net, netdev_net); 3660 + mutex_lock(&dev->mlx5e_res.uplink_netdev_lock); 3661 + if (dev->mlx5e_res.uplink_netdev) { 3662 + netdev_net = dev_net(dev->mlx5e_res.uplink_netdev); 3663 + devl_net = devlink_net(devlink); 3664 + ret = net_eq(devl_net, netdev_net); 3665 + } 3666 + mutex_unlock(&dev->mlx5e_res.uplink_netdev_lock); 3667 + return ret; 3664 3668 } 3665 3669 3666 3670 int mlx5_eswitch_block_mode(struct mlx5_core_dev *dev) ··· 3737 3733 goto unlock; 3738 3734 } 3739 3735 3736 + esw->eswitch_operation_in_progress = true; 3737 + up_write(&esw->mode_lock); 3738 + 3740 3739 mlx5_eswitch_disable_locked(esw); 3741 3740 if (mode == DEVLINK_ESWITCH_MODE_SWITCHDEV) { 3742 3741 if (mlx5_devlink_trap_get_num_active(esw->dev)) { 3743 3742 NL_SET_ERR_MSG_MOD(extack, 3744 3743 "Can't change mode while devlink traps are active"); 3745 3744 err = -EOPNOTSUPP; 3746 - goto unlock; 3745 + goto skip; 3747 3746 } 3748 3747 err = esw_offloads_start(esw, extack); 3749 3748 } else if (mode == DEVLINK_ESWITCH_MODE_LEGACY) { ··· 3756 3749 err = -EINVAL; 3757 3750 } 3758 3751 3752 + skip: 3753 + down_write(&esw->mode_lock); 3754 + esw->eswitch_operation_in_progress = false; 3759 3755 unlock: 3760 3756 mlx5_esw_unlock(esw); 3761 3757 enable_lag: ··· 3769 3759 int mlx5_devlink_eswitch_mode_get(struct devlink *devlink, u16 *mode) 3770 3760 { 3771 3761 struct mlx5_eswitch *esw; 3772 - int err; 3773 3762 3774 3763 esw = mlx5_devlink_eswitch_get(devlink); 3775 3764 if (IS_ERR(esw)) 3776 3765 return PTR_ERR(esw); 3777 3766 3778 - down_read(&esw->mode_lock); 3779 - err = esw_mode_to_devlink(esw->mode, mode); 3780 - up_read(&esw->mode_lock); 3781 - return err; 3767 + return esw_mode_to_devlink(esw->mode, mode); 3782 3768 } 3783 3769 3784 3770 static int mlx5_esw_vports_inline_set(struct mlx5_eswitch *esw, u8 mlx5_mode, ··· 3868 3862 if (err) 3869 3863 goto out; 3870 3864 3871 - err = mlx5_esw_vports_inline_set(esw, mlx5_mode, extack); 3872 - if (err) 3873 - goto out; 3865 + esw->eswitch_operation_in_progress = true; 3866 + up_write(&esw->mode_lock); 3874 3867 3875 - esw->offloads.inline_mode = mlx5_mode; 3868 + err = mlx5_esw_vports_inline_set(esw, mlx5_mode, extack); 3869 + if (!err) 3870 + esw->offloads.inline_mode = mlx5_mode; 3871 + 3872 + down_write(&esw->mode_lock); 3873 + esw->eswitch_operation_in_progress = false; 3876 3874 up_write(&esw->mode_lock); 3877 3875 return 0; 3878 3876 ··· 3888 3878 int mlx5_devlink_eswitch_inline_mode_get(struct devlink *devlink, u8 *mode) 3889 3879 { 3890 3880 struct mlx5_eswitch *esw; 3891 - int err; 3892 3881 3893 3882 esw = mlx5_devlink_eswitch_get(devlink); 3894 3883 if (IS_ERR(esw)) 3895 3884 return PTR_ERR(esw); 3896 3885 3897 - down_read(&esw->mode_lock); 3898 - err = esw_inline_mode_to_devlink(esw->offloads.inline_mode, mode); 3899 - up_read(&esw->mode_lock); 3900 - return err; 3886 + return esw_inline_mode_to_devlink(esw->offloads.inline_mode, mode); 3901 3887 } 3902 3888 3903 3889 bool mlx5_eswitch_block_encap(struct mlx5_core_dev *dev) ··· 3975 3969 goto unlock; 3976 3970 } 3977 3971 3972 + esw->eswitch_operation_in_progress = true; 3973 + up_write(&esw->mode_lock); 3974 + 3978 3975 esw_destroy_offloads_fdb_tables(esw); 3979 3976 3980 3977 esw->offloads.encap = encap; ··· 3990 3981 esw->offloads.encap = !encap; 3991 3982 (void)esw_create_offloads_fdb_tables(esw); 3992 3983 } 3984 + 3985 + down_write(&esw->mode_lock); 3986 + esw->eswitch_operation_in_progress = false; 3993 3987 3994 3988 unlock: 3995 3989 up_write(&esw->mode_lock); ··· 4008 3996 if (IS_ERR(esw)) 4009 3997 return PTR_ERR(esw); 4010 3998 4011 - down_read(&esw->mode_lock); 4012 3999 *encap = esw->offloads.encap; 4013 - up_read(&esw->mode_lock); 4014 4000 return 0; 4015 4001 } 4016 4002
+29
drivers/net/ethernet/mellanox/mlx5/core/fw_reset.c
··· 325 325 mlx5_core_err(dev, "Failed to reload FW tracer\n"); 326 326 } 327 327 328 + #if IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE) 329 + static int mlx5_check_hotplug_interrupt(struct mlx5_core_dev *dev) 330 + { 331 + struct pci_dev *bridge = dev->pdev->bus->self; 332 + u16 reg16; 333 + int err; 334 + 335 + if (!bridge) 336 + return -EOPNOTSUPP; 337 + 338 + err = pcie_capability_read_word(bridge, PCI_EXP_SLTCTL, &reg16); 339 + if (err) 340 + return err; 341 + 342 + if ((reg16 & PCI_EXP_SLTCTL_HPIE) && (reg16 & PCI_EXP_SLTCTL_DLLSCE)) { 343 + mlx5_core_warn(dev, "FW reset is not supported as HotPlug is enabled\n"); 344 + return -EOPNOTSUPP; 345 + } 346 + 347 + return 0; 348 + } 349 + #endif 350 + 328 351 static int mlx5_check_dev_ids(struct mlx5_core_dev *dev, u16 dev_id) 329 352 { 330 353 struct pci_bus *bridge_bus = dev->pdev->bus; ··· 379 356 mlx5_core_warn(dev, "fast teardown is not supported by firmware\n"); 380 357 return false; 381 358 } 359 + 360 + #if IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE) 361 + err = mlx5_check_hotplug_interrupt(dev); 362 + if (err) 363 + return false; 364 + #endif 382 365 383 366 err = pci_read_config_word(dev->pdev, PCI_DEVICE_ID, &dev_id); 384 367 if (err)
+1
drivers/net/ethernet/qlogic/qed/qed_cxt.c
··· 933 933 p_dma->virt_addr = NULL; 934 934 } 935 935 kfree(p_mngr->ilt_shadow); 936 + p_mngr->ilt_shadow = NULL; 936 937 } 937 938 938 939 static int qed_ilt_blk_alloc(struct qed_hwfn *p_hwfn,
+9 -8
drivers/net/ethernet/qualcomm/qca_debug.c
··· 30 30 31 31 #define QCASPI_MAX_REGS 0x20 32 32 33 + #define QCASPI_RX_MAX_FRAMES 4 34 + 33 35 static const u16 qcaspi_spi_regs[] = { 34 36 SPI_REG_BFR_SIZE, 35 37 SPI_REG_WRBUF_SPC_AVA, ··· 254 252 { 255 253 struct qcaspi *qca = netdev_priv(dev); 256 254 257 - ring->rx_max_pending = 4; 255 + ring->rx_max_pending = QCASPI_RX_MAX_FRAMES; 258 256 ring->tx_max_pending = TX_RING_MAX_LEN; 259 - ring->rx_pending = 4; 257 + ring->rx_pending = QCASPI_RX_MAX_FRAMES; 260 258 ring->tx_pending = qca->txr.count; 261 259 } 262 260 ··· 265 263 struct kernel_ethtool_ringparam *kernel_ring, 266 264 struct netlink_ext_ack *extack) 267 265 { 268 - const struct net_device_ops *ops = dev->netdev_ops; 269 266 struct qcaspi *qca = netdev_priv(dev); 270 267 271 - if ((ring->rx_pending) || 268 + if (ring->rx_pending != QCASPI_RX_MAX_FRAMES || 272 269 (ring->rx_mini_pending) || 273 270 (ring->rx_jumbo_pending)) 274 271 return -EINVAL; 275 272 276 - if (netif_running(dev)) 277 - ops->ndo_stop(dev); 273 + if (qca->spi_thread) 274 + kthread_park(qca->spi_thread); 278 275 279 276 qca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN); 280 277 qca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN); 281 278 282 - if (netif_running(dev)) 283 - ops->ndo_open(dev); 279 + if (qca->spi_thread) 280 + kthread_unpark(qca->spi_thread); 284 281 285 282 return 0; 286 283 }
+19 -1
drivers/net/ethernet/qualcomm/qca_spi.c
··· 580 580 netdev_info(qca->net_dev, "SPI thread created\n"); 581 581 while (!kthread_should_stop()) { 582 582 set_current_state(TASK_INTERRUPTIBLE); 583 + if (kthread_should_park()) { 584 + netif_tx_disable(qca->net_dev); 585 + netif_carrier_off(qca->net_dev); 586 + qcaspi_flush_tx_ring(qca); 587 + kthread_parkme(); 588 + if (qca->sync == QCASPI_SYNC_READY) { 589 + netif_carrier_on(qca->net_dev); 590 + netif_wake_queue(qca->net_dev); 591 + } 592 + continue; 593 + } 594 + 583 595 if ((qca->intr_req == qca->intr_svc) && 584 596 !qca->txr.skb[qca->txr.head]) 585 597 schedule(); ··· 620 608 if (intr_cause & SPI_INT_CPU_ON) { 621 609 qcaspi_qca7k_sync(qca, QCASPI_EVENT_CPUON); 622 610 611 + /* Frame decoding in progress */ 612 + if (qca->frm_handle.state != qca->frm_handle.init) 613 + qca->net_dev->stats.rx_dropped++; 614 + 615 + qcafrm_fsm_init_spi(&qca->frm_handle); 616 + qca->stats.device_reset++; 617 + 623 618 /* not synced. */ 624 619 if (qca->sync != QCASPI_SYNC_READY) 625 620 continue; 626 621 627 - qca->stats.device_reset++; 628 622 netif_wake_queue(qca->net_dev); 629 623 netif_carrier_on(qca->net_dev); 630 624 }
+6 -13
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
··· 59 59 return -ENODEV; 60 60 } 61 61 62 - if (!of_device_is_compatible(np, "loongson, pci-gmac")) { 63 - pr_info("dwmac_loongson_pci: Incompatible OF node\n"); 64 - return -ENODEV; 65 - } 66 - 67 62 plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL); 68 63 if (!plat) 64 + return -ENOMEM; 65 + 66 + plat->mdio_bus_data = devm_kzalloc(&pdev->dev, 67 + sizeof(*plat->mdio_bus_data), 68 + GFP_KERNEL); 69 + if (!plat->mdio_bus_data) 69 70 return -ENOMEM; 70 71 71 72 plat->mdio_node = of_get_child_by_name(np, "mdio"); 72 73 if (plat->mdio_node) { 73 74 dev_info(&pdev->dev, "Found MDIO subnode\n"); 74 - 75 - plat->mdio_bus_data = devm_kzalloc(&pdev->dev, 76 - sizeof(*plat->mdio_bus_data), 77 - GFP_KERNEL); 78 - if (!plat->mdio_bus_data) { 79 - ret = -ENOMEM; 80 - goto err_put_node; 81 - } 82 75 plat->mdio_bus_data->needs_reset = true; 83 76 } 84 77
+10
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 34 34 #define RGMII_CONFIG_LOOPBACK_EN BIT(2) 35 35 #define RGMII_CONFIG_PROG_SWAP BIT(1) 36 36 #define RGMII_CONFIG_DDR_MODE BIT(0) 37 + #define RGMII_CONFIG_SGMII_CLK_DVDR GENMASK(18, 10) 37 38 38 39 /* SDCC_HC_REG_DLL_CONFIG fields */ 39 40 #define SDCC_DLL_CONFIG_DLL_RST BIT(30) ··· 78 77 /* MAC_CTRL_REG bits */ 79 78 #define ETHQOS_MAC_CTRL_SPEED_MODE BIT(14) 80 79 #define ETHQOS_MAC_CTRL_PORT_SEL BIT(15) 80 + 81 + #define SGMII_10M_RX_CLK_DVDR 0x31 81 82 82 83 struct ethqos_emac_por { 83 84 unsigned int offset; ··· 601 598 return 0; 602 599 } 603 600 601 + /* On interface toggle MAC registers gets reset. 602 + * Configure MAC block for SGMII on ethernet phy link up 603 + */ 604 604 static int ethqos_configure_sgmii(struct qcom_ethqos *ethqos) 605 605 { 606 606 int val; ··· 623 617 case SPEED_10: 624 618 val |= ETHQOS_MAC_CTRL_PORT_SEL; 625 619 val &= ~ETHQOS_MAC_CTRL_SPEED_MODE; 620 + rgmii_updatel(ethqos, RGMII_CONFIG_SGMII_CLK_DVDR, 621 + FIELD_PREP(RGMII_CONFIG_SGMII_CLK_DVDR, 622 + SGMII_10M_RX_CLK_DVDR), 623 + RGMII_IO_MACRO_CONFIG); 626 624 break; 627 625 } 628 626
+5 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 591 591 new_bus->parent = priv->device; 592 592 593 593 err = of_mdiobus_register(new_bus, mdio_node); 594 - if (err != 0) { 594 + if (err == -ENODEV) { 595 + err = 0; 596 + dev_info(dev, "MDIO bus is disabled\n"); 597 + goto bus_register_fail; 598 + } else if (err) { 595 599 dev_err_probe(dev, err, "Cannot register the MDIO bus\n"); 596 600 goto bus_register_fail; 597 601 }
+3 -1
drivers/net/team/team.c
··· 281 281 return 0; 282 282 283 283 inst_rollback: 284 - for (i--; i >= 0; i--) 284 + for (i--; i >= 0; i--) { 285 285 __team_option_inst_del_option(team, dst_opts[i]); 286 + list_del(&dst_opts[i]->list); 287 + } 286 288 287 289 i = option_count; 288 290 alloc_rollback:
+8 -1
include/linux/mlx5/mlx5_ifc.h
··· 621 621 622 622 u8 reserved_at_140[0x8]; 623 623 u8 bth_dst_qp[0x18]; 624 - u8 reserved_at_160[0x20]; 624 + u8 inner_esp_spi[0x20]; 625 625 u8 outer_esp_spi[0x20]; 626 626 u8 reserved_at_1a0[0x60]; 627 627 }; ··· 11999 11999 MLX5_IPSEC_ASO_MODE = 0x0, 12000 12000 MLX5_IPSEC_ASO_REPLAY_PROTECTION = 0x1, 12001 12001 MLX5_IPSEC_ASO_INC_SN = 0x2, 12002 + }; 12003 + 12004 + enum { 12005 + MLX5_IPSEC_ASO_REPLAY_WIN_32BIT = 0x0, 12006 + MLX5_IPSEC_ASO_REPLAY_WIN_64BIT = 0x1, 12007 + MLX5_IPSEC_ASO_REPLAY_WIN_128BIT = 0x2, 12008 + MLX5_IPSEC_ASO_REPLAY_WIN_256BIT = 0x3, 12002 12009 }; 12003 12010 12004 12011 struct mlx5_ifc_ipsec_aso_bits {
+10 -2
include/net/addrconf.h
··· 31 31 __u8 length; 32 32 __u8 prefix_len; 33 33 34 + union __packed { 35 + __u8 flags; 36 + struct __packed { 34 37 #if defined(__BIG_ENDIAN_BITFIELD) 35 - __u8 onlink : 1, 38 + __u8 onlink : 1, 36 39 autoconf : 1, 37 40 reserved : 6; 38 41 #elif defined(__LITTLE_ENDIAN_BITFIELD) 39 - __u8 reserved : 6, 42 + __u8 reserved : 6, 40 43 autoconf : 1, 41 44 onlink : 1; 42 45 #else 43 46 #error "Please fix <asm/byteorder.h>" 44 47 #endif 48 + }; 49 + }; 45 50 __be32 valid; 46 51 __be32 prefered; 47 52 __be32 reserved2; 48 53 49 54 struct in6_addr prefix; 50 55 }; 56 + 57 + /* rfc4861 4.6.2: IPv6 PIO is 32 bytes in size */ 58 + static_assert(sizeof(struct prefix_info) == 32); 51 59 52 60 #include <linux/ipv6.h> 53 61 #include <linux/netdevice.h>
-4
include/net/if_inet6.h
··· 22 22 #define IF_RS_SENT 0x10 23 23 #define IF_READY 0x80000000 24 24 25 - /* prefix flags */ 26 - #define IF_PREFIX_ONLINK 0x01 27 - #define IF_PREFIX_AUTOCONF 0x02 28 - 29 25 enum { 30 26 INET6_IFADDR_STATE_PREDAD, 31 27 INET6_IFADDR_STATE_DAD,
+10
include/net/netfilter/nf_flow_table.h
··· 62 62 enum flow_offload_tuple_dir dir, 63 63 struct nf_flow_rule *flow_rule); 64 64 void (*free)(struct nf_flowtable *ft); 65 + void (*get)(struct nf_flowtable *ft); 66 + void (*put)(struct nf_flowtable *ft); 65 67 nf_hookfn *hook; 66 68 struct module *owner; 67 69 }; ··· 242 240 } 243 241 244 242 list_add_tail(&block_cb->list, &block->cb_list); 243 + up_write(&flow_table->flow_block_lock); 244 + 245 + if (flow_table->type->get) 246 + flow_table->type->get(flow_table); 247 + return 0; 245 248 246 249 unlock: 247 250 up_write(&flow_table->flow_block_lock); ··· 269 262 WARN_ON(true); 270 263 } 271 264 up_write(&flow_table->flow_block_lock); 265 + 266 + if (flow_table->type->put) 267 + flow_table->type->put(flow_table); 272 268 } 273 269 274 270 void flow_offload_route_init(struct flow_offload *flow,
+4 -5
net/appletalk/ddp.c
··· 1775 1775 break; 1776 1776 } 1777 1777 case TIOCINQ: { 1778 - /* 1779 - * These two are safe on a single CPU system as only 1780 - * user tasks fiddle here 1781 - */ 1782 - struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); 1778 + struct sk_buff *skb; 1783 1779 long amount = 0; 1784 1780 1781 + spin_lock_irq(&sk->sk_receive_queue.lock); 1782 + skb = skb_peek(&sk->sk_receive_queue); 1785 1783 if (skb) 1786 1784 amount = skb->len - sizeof(struct ddpehdr); 1785 + spin_unlock_irq(&sk->sk_receive_queue.lock); 1787 1786 rc = put_user(amount, (int __user *)argp); 1788 1787 break; 1789 1788 }
+5 -2
net/atm/ioctl.c
··· 73 73 case SIOCINQ: 74 74 { 75 75 struct sk_buff *skb; 76 + int amount; 76 77 77 78 if (sock->state != SS_CONNECTED) { 78 79 error = -EINVAL; 79 80 goto done; 80 81 } 82 + spin_lock_irq(&sk->sk_receive_queue.lock); 81 83 skb = skb_peek(&sk->sk_receive_queue); 82 - error = put_user(skb ? skb->len : 0, 83 - (int __user *)argp) ? -EFAULT : 0; 84 + amount = skb ? skb->len : 0; 85 + spin_unlock_irq(&sk->sk_receive_queue.lock); 86 + error = put_user(amount, (int __user *)argp) ? -EFAULT : 0; 84 87 goto done; 85 88 } 86 89 case ATM_SETSC:
+8 -1
net/core/neighbour.c
··· 253 253 { 254 254 int max_clean = atomic_read(&tbl->gc_entries) - 255 255 READ_ONCE(tbl->gc_thresh2); 256 + u64 tmax = ktime_get_ns() + NSEC_PER_MSEC; 256 257 unsigned long tref = jiffies - 5 * HZ; 257 258 struct neighbour *n, *tmp; 258 259 int shrunk = 0; 260 + int loop = 0; 259 261 260 262 NEIGH_CACHE_STAT_INC(tbl, forced_gc_runs); 261 263 ··· 280 278 shrunk++; 281 279 if (shrunk >= max_clean) 282 280 break; 281 + if (++loop == 16) { 282 + if (ktime_get_ns() > tmax) 283 + goto unlock; 284 + loop = 0; 285 + } 283 286 } 284 287 } 285 288 286 289 WRITE_ONCE(tbl->last_flush, jiffies); 287 - 290 + unlock: 288 291 write_unlock_bh(&tbl->lock); 289 292 290 293 return shrunk;
+2 -1
net/core/skbuff.c
··· 4522 4522 /* GSO partial only requires that we trim off any excess that 4523 4523 * doesn't fit into an MSS sized block, so take care of that 4524 4524 * now. 4525 + * Cap len to not accidentally hit GSO_BY_FRAGS. 4525 4526 */ 4526 - partial_segs = len / mss; 4527 + partial_segs = min(len, GSO_BY_FRAGS - 1) / mss; 4527 4528 if (partial_segs > 1) 4528 4529 mss *= partial_segs; 4529 4530 else
+20 -2
net/ipv4/tcp_input.c
··· 4368 4368 * up to bandwidth of 18Gigabit/sec. 8) ] 4369 4369 */ 4370 4370 4371 + /* Estimates max number of increments of remote peer TSval in 4372 + * a replay window (based on our current RTO estimation). 4373 + */ 4374 + static u32 tcp_tsval_replay(const struct sock *sk) 4375 + { 4376 + /* If we use usec TS resolution, 4377 + * then expect the remote peer to use the same resolution. 4378 + */ 4379 + if (tcp_sk(sk)->tcp_usec_ts) 4380 + return inet_csk(sk)->icsk_rto * (USEC_PER_SEC / HZ); 4381 + 4382 + /* RFC 7323 recommends a TSval clock between 1ms and 1sec. 4383 + * We know that some OS (including old linux) can use 1200 Hz. 4384 + */ 4385 + return inet_csk(sk)->icsk_rto * 1200 / HZ; 4386 + } 4387 + 4371 4388 static int tcp_disordered_ack(const struct sock *sk, const struct sk_buff *skb) 4372 4389 { 4373 4390 const struct tcp_sock *tp = tcp_sk(sk); ··· 4392 4375 u32 seq = TCP_SKB_CB(skb)->seq; 4393 4376 u32 ack = TCP_SKB_CB(skb)->ack_seq; 4394 4377 4395 - return (/* 1. Pure ACK with correct sequence number. */ 4378 + return /* 1. Pure ACK with correct sequence number. */ 4396 4379 (th->ack && seq == TCP_SKB_CB(skb)->end_seq && seq == tp->rcv_nxt) && 4397 4380 4398 4381 /* 2. ... and duplicate ACK. */ ··· 4402 4385 !tcp_may_update_window(tp, ack, seq, ntohs(th->window) << tp->rx_opt.snd_wscale) && 4403 4386 4404 4387 /* 4. ... and sits in replay window. */ 4405 - (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= (inet_csk(sk)->icsk_rto * 1024) / HZ); 4388 + (s32)(tp->rx_opt.ts_recent - tp->rx_opt.rcv_tsval) <= 4389 + tcp_tsval_replay(sk); 4406 4390 } 4407 4391 4408 4392 static inline bool tcp_paws_discard(const struct sock *sk,
+6
net/ipv4/tcp_output.c
··· 3293 3293 if (skb_still_in_host_queue(sk, skb)) 3294 3294 return -EBUSY; 3295 3295 3296 + start: 3296 3297 if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) { 3298 + if (unlikely(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) { 3299 + TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_SYN; 3300 + TCP_SKB_CB(skb)->seq++; 3301 + goto start; 3302 + } 3297 3303 if (unlikely(before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))) { 3298 3304 WARN_ON_ONCE(1); 3299 3305 return -EINVAL;
+1 -5
net/ipv6/addrconf.c
··· 6149 6149 pmsg->prefix_len = pinfo->prefix_len; 6150 6150 pmsg->prefix_type = pinfo->type; 6151 6151 pmsg->prefix_pad3 = 0; 6152 - pmsg->prefix_flags = 0; 6153 - if (pinfo->onlink) 6154 - pmsg->prefix_flags |= IF_PREFIX_ONLINK; 6155 - if (pinfo->autoconf) 6156 - pmsg->prefix_flags |= IF_PREFIX_AUTOCONF; 6152 + pmsg->prefix_flags = pinfo->flags; 6157 6153 6158 6154 if (nla_put(skb, PREFIX_ADDRESS, sizeof(pinfo->prefix), &pinfo->prefix)) 6159 6155 goto nla_put_failure;
+3 -1
net/rose/af_rose.c
··· 1315 1315 case TIOCINQ: { 1316 1316 struct sk_buff *skb; 1317 1317 long amount = 0L; 1318 - /* These two are safe on a single CPU system as only user tasks fiddle here */ 1318 + 1319 + spin_lock_irq(&sk->sk_receive_queue.lock); 1319 1320 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1320 1321 amount = skb->len; 1322 + spin_unlock_irq(&sk->sk_receive_queue.lock); 1321 1323 return put_user(amount, (unsigned int __user *) argp); 1322 1324 } 1323 1325
+28 -6
net/sched/act_ct.c
··· 286 286 !test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags); 287 287 } 288 288 289 + static void tcf_ct_flow_table_get_ref(struct tcf_ct_flow_table *ct_ft); 290 + 291 + static void tcf_ct_nf_get(struct nf_flowtable *ft) 292 + { 293 + struct tcf_ct_flow_table *ct_ft = 294 + container_of(ft, struct tcf_ct_flow_table, nf_ft); 295 + 296 + tcf_ct_flow_table_get_ref(ct_ft); 297 + } 298 + 299 + static void tcf_ct_flow_table_put(struct tcf_ct_flow_table *ct_ft); 300 + 301 + static void tcf_ct_nf_put(struct nf_flowtable *ft) 302 + { 303 + struct tcf_ct_flow_table *ct_ft = 304 + container_of(ft, struct tcf_ct_flow_table, nf_ft); 305 + 306 + tcf_ct_flow_table_put(ct_ft); 307 + } 308 + 289 309 static struct nf_flowtable_type flowtable_ct = { 290 310 .gc = tcf_ct_flow_is_outdated, 291 311 .action = tcf_ct_flow_table_fill_actions, 312 + .get = tcf_ct_nf_get, 313 + .put = tcf_ct_nf_put, 292 314 .owner = THIS_MODULE, 293 315 }; 294 316 ··· 359 337 return err; 360 338 } 361 339 340 + static void tcf_ct_flow_table_get_ref(struct tcf_ct_flow_table *ct_ft) 341 + { 342 + refcount_inc(&ct_ft->ref); 343 + } 344 + 362 345 static void tcf_ct_flow_table_cleanup_work(struct work_struct *work) 363 346 { 364 - struct flow_block_cb *block_cb, *tmp_cb; 365 347 struct tcf_ct_flow_table *ct_ft; 366 348 struct flow_block *block; 367 349 ··· 373 347 rwork); 374 348 nf_flow_table_free(&ct_ft->nf_ft); 375 349 376 - /* Remove any remaining callbacks before cleanup */ 377 350 block = &ct_ft->nf_ft.flow_block; 378 351 down_write(&ct_ft->nf_ft.flow_block_lock); 379 - list_for_each_entry_safe(block_cb, tmp_cb, &block->cb_list, list) { 380 - list_del(&block_cb->list); 381 - flow_block_cb_free(block_cb); 382 - } 352 + WARN_ON(!list_empty(&block->cb_list)); 383 353 up_write(&ct_ft->nf_ft.flow_block_lock); 384 354 kfree(ct_ft); 385 355
+1 -1
net/vmw_vsock/virtio_transport_common.c
··· 843 843 struct virtio_vsock_sock *vvs = vsk->trans; 844 844 s64 bytes; 845 845 846 - bytes = vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); 846 + bytes = (s64)vvs->peer_buf_alloc - (vvs->tx_cnt - vvs->peer_fwd_cnt); 847 847 if (bytes < 0) 848 848 bytes = 0; 849 849