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

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

Pull networking fixes from Paolo Abeni:
"Including fixes from netfilter, wireless and ebpf.

Current release - regressions:

- netfilter: conntrack: gre: don't set assured flag for clash entries

- wifi: iwlwifi: remove 'use_tfh' config to fix crash

Previous releases - regressions:

- ipv6: fix a potential refcount underflow for idev

- icmp6: ifix null-ptr-deref of ip6_null_entry->rt6i_idev in
icmp6_dev()

- bpf: fix max stack depth check for async callbacks

- eth: mlx5e:
- check for NOT_READY flag state after locking
- fix page_pool page fragment tracking for XDP

- eth: igc:
- fix tx hang issue when QBV gate is closed
- fix corner cases for TSN offload

- eth: octeontx2-af: Move validation of ptp pointer before its usage

- eth: ena: fix shift-out-of-bounds in exponential backoff

Previous releases - always broken:

- core: prevent skb corruption on frag list segmentation

- sched:
- cls_fw: fix improper refcount update leads to use-after-free
- sch_qfq: account for stab overhead in qfq_enqueue

- netfilter:
- report use refcount overflow
- prevent OOB access in nft_byteorder_eval

- wifi: mt7921e: fix init command fail with enabled device

- eth: ocelot: fix oversize frame dropping for preemptible TCs

- eth: fec: recycle pages for transmitted XDP frames"

* tag 'net-6.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (79 commits)
selftests: tc-testing: add test for qfq with stab overhead
net/sched: sch_qfq: account for stab overhead in qfq_enqueue
selftests: tc-testing: add tests for qfq mtu sanity check
net/sched: sch_qfq: reintroduce lmax bound check for MTU
wifi: cfg80211: fix receiving mesh packets without RFC1042 header
wifi: rtw89: debug: fix error code in rtw89_debug_priv_send_h2c_set()
net: txgbe: fix eeprom calculation error
net/sched: make psched_mtu() RTNL-less safe
net: ena: fix shift-out-of-bounds in exponential backoff
netdevsim: fix uninitialized data in nsim_dev_trap_fa_cookie_write()
net/sched: flower: Ensure both minimum and maximum ports are specified
MAINTAINERS: Add another mailing list for QUALCOMM ETHQOS ETHERNET DRIVER
docs: netdev: update the URL of the status page
wifi: iwlwifi: remove 'use_tfh' config to fix crash
xdp: use trusted arguments in XDP hints kfuncs
bpf: cpumap: Fix memory leak in cpu_map_update_elem
wifi: airo: avoid uninitialized warning in airo_get_rate()
octeontx2-pf: Add additional check for MCAM rules
net: dsa: Removed unneeded of_node_put in felix_parse_ports_node
net: fec: use netdev_err_once() instead of netdev_err()
...

+1018 -528
+1 -1
Documentation/process/maintainer-netdev.rst
··· 98 98 repository link above for any new networking-related commits. You may 99 99 also check the following website for the current status: 100 100 101 - http://vger.kernel.org/~davem/net-next.html 101 + https://patchwork.hopto.org/net-next.html 102 102 103 103 The ``net`` tree continues to collect fixes for the vX.Y content, and is 104 104 fed back to Linus at regular (~weekly) intervals. Meaning that the
+1
MAINTAINERS
··· 17543 17543 M: Vinod Koul <vkoul@kernel.org> 17544 17544 R: Bhupesh Sharma <bhupesh.sharma@linaro.org> 17545 17545 L: netdev@vger.kernel.org 17546 + L: linux-arm-msm@vger.kernel.org 17546 17547 S: Maintained 17547 17548 F: Documentation/devicetree/bindings/net/qcom,ethqos.yaml 17548 17549 F: drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+3 -3
arch/riscv/net/bpf_jit.h
··· 69 69 struct bpf_prog *prog; 70 70 u16 *insns; /* RV insns */ 71 71 int ninsns; 72 - int body_len; 72 + int prologue_len; 73 73 int epilogue_offset; 74 74 int *offset; /* BPF to RV */ 75 75 int nexentries; ··· 216 216 int from, to; 217 217 218 218 off++; /* BPF branch is from PC+1, RV is from PC */ 219 - from = (insn > 0) ? ctx->offset[insn - 1] : 0; 220 - to = (insn + off > 0) ? ctx->offset[insn + off - 1] : 0; 219 + from = (insn > 0) ? ctx->offset[insn - 1] : ctx->prologue_len; 220 + to = (insn + off > 0) ? ctx->offset[insn + off - 1] : ctx->prologue_len; 221 221 return ninsns_rvoff(to - from); 222 222 } 223 223
+13 -6
arch/riscv/net/bpf_jit_core.c
··· 44 44 unsigned int prog_size = 0, extable_size = 0; 45 45 bool tmp_blinded = false, extra_pass = false; 46 46 struct bpf_prog *tmp, *orig_prog = prog; 47 - int pass = 0, prev_ninsns = 0, prologue_len, i; 47 + int pass = 0, prev_ninsns = 0, i; 48 48 struct rv_jit_data *jit_data; 49 49 struct rv_jit_context *ctx; 50 50 ··· 83 83 prog = orig_prog; 84 84 goto out_offset; 85 85 } 86 + 87 + if (build_body(ctx, extra_pass, NULL)) { 88 + prog = orig_prog; 89 + goto out_offset; 90 + } 91 + 86 92 for (i = 0; i < prog->len; i++) { 87 93 prev_ninsns += 32; 88 94 ctx->offset[i] = prev_ninsns; ··· 97 91 for (i = 0; i < NR_JIT_ITERATIONS; i++) { 98 92 pass++; 99 93 ctx->ninsns = 0; 94 + 95 + bpf_jit_build_prologue(ctx); 96 + ctx->prologue_len = ctx->ninsns; 97 + 100 98 if (build_body(ctx, extra_pass, ctx->offset)) { 101 99 prog = orig_prog; 102 100 goto out_offset; 103 101 } 104 - ctx->body_len = ctx->ninsns; 105 - bpf_jit_build_prologue(ctx); 102 + 106 103 ctx->epilogue_offset = ctx->ninsns; 107 104 bpf_jit_build_epilogue(ctx); 108 105 ··· 171 162 172 163 if (!prog->is_func || extra_pass) { 173 164 bpf_jit_binary_lock_ro(jit_data->header); 174 - prologue_len = ctx->epilogue_offset - ctx->body_len; 175 165 for (i = 0; i < prog->len; i++) 176 - ctx->offset[i] = ninsns_rvoff(prologue_len + 177 - ctx->offset[i]); 166 + ctx->offset[i] = ninsns_rvoff(ctx->offset[i]); 178 167 bpf_prog_fill_jited_linfo(prog, ctx->offset); 179 168 out_offset: 180 169 kfree(ctx->offset);
+4 -6
drivers/net/dsa/ocelot/felix.c
··· 1286 1286 if (err < 0) { 1287 1287 dev_info(dev, "Unsupported PHY mode %s on port %d\n", 1288 1288 phy_modes(phy_mode), port); 1289 - of_node_put(child); 1290 1289 1291 1290 /* Leave port_phy_modes[port] = 0, which is also 1292 1291 * PHY_INTERFACE_MODE_NA. This will perform a ··· 1785 1786 { 1786 1787 struct ocelot *ocelot = ds->priv; 1787 1788 struct ocelot_port *ocelot_port = ocelot->ports[port]; 1788 - struct felix *felix = ocelot_to_felix(ocelot); 1789 1789 1790 1790 ocelot_port_set_maxlen(ocelot, port, new_mtu); 1791 1791 1792 - mutex_lock(&ocelot->tas_lock); 1792 + mutex_lock(&ocelot->fwd_domain_lock); 1793 1793 1794 - if (ocelot_port->taprio && felix->info->tas_guard_bands_update) 1795 - felix->info->tas_guard_bands_update(ocelot, port); 1794 + if (ocelot_port->taprio && ocelot->ops->tas_guard_bands_update) 1795 + ocelot->ops->tas_guard_bands_update(ocelot, port); 1796 1796 1797 - mutex_unlock(&ocelot->tas_lock); 1797 + mutex_unlock(&ocelot->fwd_domain_lock); 1798 1798 1799 1799 return 0; 1800 1800 }
-1
drivers/net/dsa/ocelot/felix.h
··· 57 57 void (*mdio_bus_free)(struct ocelot *ocelot); 58 58 int (*port_setup_tc)(struct dsa_switch *ds, int port, 59 59 enum tc_setup_type type, void *type_data); 60 - void (*tas_guard_bands_update)(struct ocelot *ocelot, int port); 61 60 void (*port_sched_speed_set)(struct ocelot *ocelot, int port, 62 61 u32 speed); 63 62 void (*phylink_mac_config)(struct ocelot *ocelot, int port,
+40 -19
drivers/net/dsa/ocelot/felix_vsc9959.c
··· 1209 1209 static void vsc9959_tas_guard_bands_update(struct ocelot *ocelot, int port) 1210 1210 { 1211 1211 struct ocelot_port *ocelot_port = ocelot->ports[port]; 1212 + struct ocelot_mm_state *mm = &ocelot->mm[port]; 1212 1213 struct tc_taprio_qopt_offload *taprio; 1213 1214 u64 min_gate_len[OCELOT_NUM_TC]; 1215 + u32 val, maxlen, add_frag_size; 1216 + u64 needed_min_frag_time_ps; 1214 1217 int speed, picos_per_byte; 1215 1218 u64 needed_bit_time_ps; 1216 - u32 val, maxlen; 1217 1219 u8 tas_speed; 1218 1220 int tc; 1219 1221 1220 - lockdep_assert_held(&ocelot->tas_lock); 1222 + lockdep_assert_held(&ocelot->fwd_domain_lock); 1221 1223 1222 1224 taprio = ocelot_port->taprio; 1223 1225 ··· 1255 1253 */ 1256 1254 needed_bit_time_ps = (u64)(maxlen + 24) * picos_per_byte; 1257 1255 1256 + /* Preemptible TCs don't need to pass a full MTU, the port will 1257 + * automatically emit a HOLD request when a preemptible TC gate closes 1258 + */ 1259 + val = ocelot_read_rix(ocelot, QSYS_PREEMPTION_CFG, port); 1260 + add_frag_size = QSYS_PREEMPTION_CFG_MM_ADD_FRAG_SIZE_X(val); 1261 + needed_min_frag_time_ps = picos_per_byte * 1262 + (u64)(24 + 2 * ethtool_mm_frag_size_add_to_min(add_frag_size)); 1263 + 1258 1264 dev_dbg(ocelot->dev, 1259 - "port %d: max frame size %d needs %llu ps at speed %d\n", 1260 - port, maxlen, needed_bit_time_ps, speed); 1265 + "port %d: max frame size %d needs %llu ps, %llu ps for mPackets at speed %d\n", 1266 + port, maxlen, needed_bit_time_ps, needed_min_frag_time_ps, 1267 + speed); 1261 1268 1262 1269 vsc9959_tas_min_gate_lengths(taprio, min_gate_len); 1263 - 1264 - mutex_lock(&ocelot->fwd_domain_lock); 1265 1270 1266 1271 for (tc = 0; tc < OCELOT_NUM_TC; tc++) { 1267 1272 u32 requested_max_sdu = vsc9959_tas_tc_max_sdu(taprio, tc); ··· 1278 1269 remaining_gate_len_ps = 1279 1270 vsc9959_tas_remaining_gate_len_ps(min_gate_len[tc]); 1280 1271 1281 - if (remaining_gate_len_ps > needed_bit_time_ps) { 1272 + if ((mm->active_preemptible_tcs & BIT(tc)) ? 1273 + remaining_gate_len_ps > needed_min_frag_time_ps : 1274 + remaining_gate_len_ps > needed_bit_time_ps) { 1282 1275 /* Setting QMAXSDU_CFG to 0 disables oversized frame 1283 1276 * dropping. 1284 1277 */ ··· 1334 1323 ocelot_write_rix(ocelot, maxlen, QSYS_PORT_MAX_SDU, port); 1335 1324 1336 1325 ocelot->ops->cut_through_fwd(ocelot); 1337 - 1338 - mutex_unlock(&ocelot->fwd_domain_lock); 1339 1326 } 1340 1327 1341 1328 static void vsc9959_sched_speed_set(struct ocelot *ocelot, int port, ··· 1360 1351 break; 1361 1352 } 1362 1353 1363 - mutex_lock(&ocelot->tas_lock); 1354 + mutex_lock(&ocelot->fwd_domain_lock); 1364 1355 1365 1356 ocelot_rmw_rix(ocelot, 1366 1357 QSYS_TAG_CONFIG_LINK_SPEED(tas_speed), ··· 1370 1361 if (ocelot_port->taprio) 1371 1362 vsc9959_tas_guard_bands_update(ocelot, port); 1372 1363 1373 - mutex_unlock(&ocelot->tas_lock); 1364 + mutex_unlock(&ocelot->fwd_domain_lock); 1374 1365 } 1375 1366 1376 1367 static void vsc9959_new_base_time(struct ocelot *ocelot, ktime_t base_time, ··· 1418 1409 int ret, i; 1419 1410 u32 val; 1420 1411 1421 - mutex_lock(&ocelot->tas_lock); 1412 + mutex_lock(&ocelot->fwd_domain_lock); 1422 1413 1423 1414 if (taprio->cmd == TAPRIO_CMD_DESTROY) { 1424 1415 ocelot_port_mqprio(ocelot, port, &taprio->mqprio); ··· 1430 1421 1431 1422 vsc9959_tas_guard_bands_update(ocelot, port); 1432 1423 1433 - mutex_unlock(&ocelot->tas_lock); 1424 + mutex_unlock(&ocelot->fwd_domain_lock); 1434 1425 return 0; 1435 1426 } else if (taprio->cmd != TAPRIO_CMD_REPLACE) { 1436 1427 ret = -EOPNOTSUPP; ··· 1513 1504 ocelot_port->taprio = taprio_offload_get(taprio); 1514 1505 vsc9959_tas_guard_bands_update(ocelot, port); 1515 1506 1516 - mutex_unlock(&ocelot->tas_lock); 1507 + mutex_unlock(&ocelot->fwd_domain_lock); 1517 1508 1518 1509 return 0; 1519 1510 ··· 1521 1512 taprio->mqprio.qopt.num_tc = 0; 1522 1513 ocelot_port_mqprio(ocelot, port, &taprio->mqprio); 1523 1514 err_unlock: 1524 - mutex_unlock(&ocelot->tas_lock); 1515 + mutex_unlock(&ocelot->fwd_domain_lock); 1525 1516 1526 1517 return ret; 1527 1518 } ··· 1534 1525 int port; 1535 1526 u32 val; 1536 1527 1537 - mutex_lock(&ocelot->tas_lock); 1528 + mutex_lock(&ocelot->fwd_domain_lock); 1538 1529 1539 1530 for (port = 0; port < ocelot->num_phys_ports; port++) { 1540 1531 ocelot_port = ocelot->ports[port]; ··· 1572 1563 QSYS_TAG_CONFIG_ENABLE, 1573 1564 QSYS_TAG_CONFIG, port); 1574 1565 } 1575 - mutex_unlock(&ocelot->tas_lock); 1566 + mutex_unlock(&ocelot->fwd_domain_lock); 1576 1567 } 1577 1568 1578 1569 static int vsc9959_qos_port_cbs_set(struct dsa_switch *ds, int port, ··· 1643 1634 } 1644 1635 } 1645 1636 1637 + static int vsc9959_qos_port_mqprio(struct ocelot *ocelot, int port, 1638 + struct tc_mqprio_qopt_offload *mqprio) 1639 + { 1640 + int ret; 1641 + 1642 + mutex_lock(&ocelot->fwd_domain_lock); 1643 + ret = ocelot_port_mqprio(ocelot, port, mqprio); 1644 + mutex_unlock(&ocelot->fwd_domain_lock); 1645 + 1646 + return ret; 1647 + } 1648 + 1646 1649 static int vsc9959_port_setup_tc(struct dsa_switch *ds, int port, 1647 1650 enum tc_setup_type type, 1648 1651 void *type_data) ··· 1667 1646 case TC_SETUP_QDISC_TAPRIO: 1668 1647 return vsc9959_qos_port_tas_set(ocelot, port, type_data); 1669 1648 case TC_SETUP_QDISC_MQPRIO: 1670 - return ocelot_port_mqprio(ocelot, port, type_data); 1649 + return vsc9959_qos_port_mqprio(ocelot, port, type_data); 1671 1650 case TC_SETUP_QDISC_CBS: 1672 1651 return vsc9959_qos_port_cbs_set(ds, port, type_data); 1673 1652 default: ··· 2612 2591 .cut_through_fwd = vsc9959_cut_through_fwd, 2613 2592 .tas_clock_adjust = vsc9959_tas_clock_adjust, 2614 2593 .update_stats = vsc9959_update_stats, 2594 + .tas_guard_bands_update = vsc9959_tas_guard_bands_update, 2615 2595 }; 2616 2596 2617 2597 static const struct felix_info felix_info_vsc9959 = { ··· 2638 2616 .port_modes = vsc9959_port_modes, 2639 2617 .port_setup_tc = vsc9959_port_setup_tc, 2640 2618 .port_sched_speed_set = vsc9959_sched_speed_set, 2641 - .tas_guard_bands_update = vsc9959_tas_guard_bands_update, 2642 2619 }; 2643 2620 2644 2621 /* The INTB interrupt is shared between for PTP TX timestamp availability
+3
drivers/net/dsa/qca/qca8k-8xxx.c
··· 588 588 bool ack; 589 589 int ret; 590 590 591 + if (!skb) 592 + return -ENOMEM; 593 + 591 594 reinit_completion(&mgmt_eth_data->rw_done); 592 595 593 596 /* Increment seq_num and set it in the copy pkt */
+3
drivers/net/ethernet/amazon/ena/ena_com.c
··· 35 35 36 36 #define ENA_REGS_ADMIN_INTR_MASK 1 37 37 38 + #define ENA_MAX_BACKOFF_DELAY_EXP 16U 39 + 38 40 #define ENA_MIN_ADMIN_POLL_US 100 39 41 40 42 #define ENA_MAX_ADMIN_POLL_US 5000 ··· 538 536 539 537 static void ena_delay_exponential_backoff_us(u32 exp, u32 delay_us) 540 538 { 539 + exp = min_t(u32, exp, ENA_MAX_BACKOFF_DELAY_EXP); 541 540 delay_us = max_t(u32, ENA_MIN_ADMIN_POLL_US, delay_us); 542 541 delay_us = min_t(u32, delay_us * (1U << exp), ENA_MAX_ADMIN_POLL_US); 543 542 usleep_range(delay_us, 2 * delay_us);
+2 -2
drivers/net/ethernet/broadcom/bgmac.c
··· 1492 1492 1493 1493 bgmac->in_init = true; 1494 1494 1495 - bgmac_chip_intrs_off(bgmac); 1496 - 1497 1495 net_dev->irq = bgmac->irq; 1498 1496 SET_NETDEV_DEV(net_dev, bgmac->dev); 1499 1497 dev_set_drvdata(bgmac->dev, bgmac); ··· 1508 1510 * Broadcom does it in arch PCI code when enabling fake PCI device. 1509 1511 */ 1510 1512 bgmac_clk_enable(bgmac, 0); 1513 + 1514 + bgmac_chip_intrs_off(bgmac); 1511 1515 1512 1516 /* This seems to be fixing IRQ by assigning OOB #6 to the core */ 1513 1517 if (!(bgmac->feature_flags & BGMAC_FEAT_IDM_MASK)) {
+15 -2
drivers/net/ethernet/freescale/fec.h
··· 355 355 #define RX_RING_SIZE (FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES) 356 356 #define FEC_ENET_TX_FRSIZE 2048 357 357 #define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE) 358 - #define TX_RING_SIZE 512 /* Must be power of two */ 358 + #define TX_RING_SIZE 1024 /* Must be power of two */ 359 359 #define TX_RING_MOD_MASK 511 /* for this to work */ 360 360 361 361 #define BD_ENET_RX_INT 0x00800000 ··· 544 544 XDP_STATS_TOTAL, 545 545 }; 546 546 547 + enum fec_txbuf_type { 548 + FEC_TXBUF_T_SKB, 549 + FEC_TXBUF_T_XDP_NDO, 550 + }; 551 + 552 + struct fec_tx_buffer { 553 + union { 554 + struct sk_buff *skb; 555 + struct xdp_frame *xdp; 556 + }; 557 + enum fec_txbuf_type type; 558 + }; 559 + 547 560 struct fec_enet_priv_tx_q { 548 561 struct bufdesc_prop bd; 549 562 unsigned char *tx_bounce[TX_RING_SIZE]; 550 - struct sk_buff *tx_skbuff[TX_RING_SIZE]; 563 + struct fec_tx_buffer tx_buf[TX_RING_SIZE]; 551 564 552 565 unsigned short tx_stop_threshold; 553 566 unsigned short tx_wake_threshold;
+112 -54
drivers/net/ethernet/freescale/fec_main.c
··· 397 397 fec16_to_cpu(bdp->cbd_sc), 398 398 fec32_to_cpu(bdp->cbd_bufaddr), 399 399 fec16_to_cpu(bdp->cbd_datlen), 400 - txq->tx_skbuff[index]); 400 + txq->tx_buf[index].skb); 401 401 bdp = fec_enet_get_nextdesc(bdp, &txq->bd); 402 402 index++; 403 403 } while (bdp != txq->bd.base); ··· 654 654 655 655 index = fec_enet_get_bd_index(last_bdp, &txq->bd); 656 656 /* Save skb pointer */ 657 - txq->tx_skbuff[index] = skb; 657 + txq->tx_buf[index].skb = skb; 658 658 659 659 /* Make sure the updates to rest of the descriptor are performed before 660 660 * transferring ownership. ··· 672 672 673 673 skb_tx_timestamp(skb); 674 674 675 - /* Make sure the update to bdp and tx_skbuff are performed before 676 - * txq->bd.cur. 677 - */ 675 + /* Make sure the update to bdp is performed before txq->bd.cur. */ 678 676 wmb(); 679 677 txq->bd.cur = bdp; 680 678 ··· 860 862 } 861 863 862 864 /* Save skb pointer */ 863 - txq->tx_skbuff[index] = skb; 865 + txq->tx_buf[index].skb = skb; 864 866 865 867 skb_tx_timestamp(skb); 866 868 txq->bd.cur = bdp; ··· 950 952 for (i = 0; i < txq->bd.ring_size; i++) { 951 953 /* Initialize the BD for every fragment in the page. */ 952 954 bdp->cbd_sc = cpu_to_fec16(0); 953 - if (bdp->cbd_bufaddr && 954 - !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) 955 - dma_unmap_single(&fep->pdev->dev, 956 - fec32_to_cpu(bdp->cbd_bufaddr), 957 - fec16_to_cpu(bdp->cbd_datlen), 958 - DMA_TO_DEVICE); 959 - if (txq->tx_skbuff[i]) { 960 - dev_kfree_skb_any(txq->tx_skbuff[i]); 961 - txq->tx_skbuff[i] = NULL; 955 + if (txq->tx_buf[i].type == FEC_TXBUF_T_SKB) { 956 + if (bdp->cbd_bufaddr && 957 + !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) 958 + dma_unmap_single(&fep->pdev->dev, 959 + fec32_to_cpu(bdp->cbd_bufaddr), 960 + fec16_to_cpu(bdp->cbd_datlen), 961 + DMA_TO_DEVICE); 962 + if (txq->tx_buf[i].skb) { 963 + dev_kfree_skb_any(txq->tx_buf[i].skb); 964 + txq->tx_buf[i].skb = NULL; 965 + } 966 + } else { 967 + if (bdp->cbd_bufaddr) 968 + dma_unmap_single(&fep->pdev->dev, 969 + fec32_to_cpu(bdp->cbd_bufaddr), 970 + fec16_to_cpu(bdp->cbd_datlen), 971 + DMA_TO_DEVICE); 972 + 973 + if (txq->tx_buf[i].xdp) { 974 + xdp_return_frame(txq->tx_buf[i].xdp); 975 + txq->tx_buf[i].xdp = NULL; 976 + } 977 + 978 + /* restore default tx buffer type: FEC_TXBUF_T_SKB */ 979 + txq->tx_buf[i].type = FEC_TXBUF_T_SKB; 962 980 } 981 + 963 982 bdp->cbd_bufaddr = cpu_to_fec32(0); 964 983 bdp = fec_enet_get_nextdesc(bdp, &txq->bd); 965 984 } ··· 1375 1360 fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) 1376 1361 { 1377 1362 struct fec_enet_private *fep; 1363 + struct xdp_frame *xdpf; 1378 1364 struct bufdesc *bdp; 1379 1365 unsigned short status; 1380 1366 struct sk_buff *skb; ··· 1403 1387 1404 1388 index = fec_enet_get_bd_index(bdp, &txq->bd); 1405 1389 1406 - skb = txq->tx_skbuff[index]; 1407 - txq->tx_skbuff[index] = NULL; 1408 - if (!IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) 1409 - dma_unmap_single(&fep->pdev->dev, 1410 - fec32_to_cpu(bdp->cbd_bufaddr), 1411 - fec16_to_cpu(bdp->cbd_datlen), 1412 - DMA_TO_DEVICE); 1413 - bdp->cbd_bufaddr = cpu_to_fec32(0); 1414 - if (!skb) 1415 - goto skb_done; 1390 + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) { 1391 + skb = txq->tx_buf[index].skb; 1392 + txq->tx_buf[index].skb = NULL; 1393 + if (bdp->cbd_bufaddr && 1394 + !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) 1395 + dma_unmap_single(&fep->pdev->dev, 1396 + fec32_to_cpu(bdp->cbd_bufaddr), 1397 + fec16_to_cpu(bdp->cbd_datlen), 1398 + DMA_TO_DEVICE); 1399 + bdp->cbd_bufaddr = cpu_to_fec32(0); 1400 + if (!skb) 1401 + goto tx_buf_done; 1402 + } else { 1403 + xdpf = txq->tx_buf[index].xdp; 1404 + if (bdp->cbd_bufaddr) 1405 + dma_unmap_single(&fep->pdev->dev, 1406 + fec32_to_cpu(bdp->cbd_bufaddr), 1407 + fec16_to_cpu(bdp->cbd_datlen), 1408 + DMA_TO_DEVICE); 1409 + bdp->cbd_bufaddr = cpu_to_fec32(0); 1410 + if (!xdpf) { 1411 + txq->tx_buf[index].type = FEC_TXBUF_T_SKB; 1412 + goto tx_buf_done; 1413 + } 1414 + } 1416 1415 1417 1416 /* Check for errors. */ 1418 1417 if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | ··· 1446 1415 ndev->stats.tx_carrier_errors++; 1447 1416 } else { 1448 1417 ndev->stats.tx_packets++; 1449 - ndev->stats.tx_bytes += skb->len; 1450 - } 1451 1418 1452 - /* NOTE: SKBTX_IN_PROGRESS being set does not imply it's we who 1453 - * are to time stamp the packet, so we still need to check time 1454 - * stamping enabled flag. 1455 - */ 1456 - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS && 1457 - fep->hwts_tx_en) && 1458 - fep->bufdesc_ex) { 1459 - struct skb_shared_hwtstamps shhwtstamps; 1460 - struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; 1461 - 1462 - fec_enet_hwtstamp(fep, fec32_to_cpu(ebdp->ts), &shhwtstamps); 1463 - skb_tstamp_tx(skb, &shhwtstamps); 1419 + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) 1420 + ndev->stats.tx_bytes += skb->len; 1421 + else 1422 + ndev->stats.tx_bytes += xdpf->len; 1464 1423 } 1465 1424 1466 1425 /* Deferred means some collisions occurred during transmit, ··· 1459 1438 if (status & BD_ENET_TX_DEF) 1460 1439 ndev->stats.collisions++; 1461 1440 1462 - /* Free the sk buffer associated with this last transmit */ 1463 - dev_kfree_skb_any(skb); 1464 - skb_done: 1465 - /* Make sure the update to bdp and tx_skbuff are performed 1441 + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) { 1442 + /* NOTE: SKBTX_IN_PROGRESS being set does not imply it's we who 1443 + * are to time stamp the packet, so we still need to check time 1444 + * stamping enabled flag. 1445 + */ 1446 + if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS && 1447 + fep->hwts_tx_en) && fep->bufdesc_ex) { 1448 + struct skb_shared_hwtstamps shhwtstamps; 1449 + struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; 1450 + 1451 + fec_enet_hwtstamp(fep, fec32_to_cpu(ebdp->ts), &shhwtstamps); 1452 + skb_tstamp_tx(skb, &shhwtstamps); 1453 + } 1454 + 1455 + /* Free the sk buffer associated with this last transmit */ 1456 + dev_kfree_skb_any(skb); 1457 + } else { 1458 + xdp_return_frame(xdpf); 1459 + 1460 + txq->tx_buf[index].xdp = NULL; 1461 + /* restore default tx buffer type: FEC_TXBUF_T_SKB */ 1462 + txq->tx_buf[index].type = FEC_TXBUF_T_SKB; 1463 + } 1464 + 1465 + tx_buf_done: 1466 + /* Make sure the update to bdp and tx_buf are performed 1466 1467 * before dirty_tx 1467 1468 */ 1468 1469 wmb(); ··· 3292 3249 for (i = 0; i < txq->bd.ring_size; i++) { 3293 3250 kfree(txq->tx_bounce[i]); 3294 3251 txq->tx_bounce[i] = NULL; 3295 - skb = txq->tx_skbuff[i]; 3296 - txq->tx_skbuff[i] = NULL; 3297 - dev_kfree_skb(skb); 3252 + 3253 + if (txq->tx_buf[i].type == FEC_TXBUF_T_SKB) { 3254 + skb = txq->tx_buf[i].skb; 3255 + txq->tx_buf[i].skb = NULL; 3256 + dev_kfree_skb(skb); 3257 + } else { 3258 + if (txq->tx_buf[i].xdp) { 3259 + xdp_return_frame(txq->tx_buf[i].xdp); 3260 + txq->tx_buf[i].xdp = NULL; 3261 + } 3262 + 3263 + txq->tx_buf[i].type = FEC_TXBUF_T_SKB; 3264 + } 3298 3265 } 3299 3266 } 3300 3267 } ··· 3349 3296 fep->total_tx_ring_size += fep->tx_queue[i]->bd.ring_size; 3350 3297 3351 3298 txq->tx_stop_threshold = FEC_MAX_SKB_DESCS; 3352 - txq->tx_wake_threshold = 3353 - (txq->bd.ring_size - txq->tx_stop_threshold) / 2; 3299 + txq->tx_wake_threshold = FEC_MAX_SKB_DESCS + 2 * MAX_SKB_FRAGS; 3354 3300 3355 3301 txq->tso_hdrs = dma_alloc_coherent(&fep->pdev->dev, 3356 3302 txq->bd.ring_size * TSO_HEADER_SIZE, ··· 3784 3732 if (fep->quirks & FEC_QUIRK_SWAP_FRAME) 3785 3733 return -EOPNOTSUPP; 3786 3734 3735 + if (!bpf->prog) 3736 + xdp_features_clear_redirect_target(dev); 3737 + 3787 3738 if (is_run) { 3788 3739 napi_disable(&fep->napi); 3789 3740 netif_tx_disable(dev); 3790 3741 } 3791 3742 3792 3743 old_prog = xchg(&fep->xdp_prog, bpf->prog); 3744 + if (old_prog) 3745 + bpf_prog_put(old_prog); 3746 + 3793 3747 fec_restart(dev); 3794 3748 3795 3749 if (is_run) { ··· 3803 3745 netif_tx_start_all_queues(dev); 3804 3746 } 3805 3747 3806 - if (old_prog) 3807 - bpf_prog_put(old_prog); 3748 + if (bpf->prog) 3749 + xdp_features_set_redirect_target(dev, false); 3808 3750 3809 3751 return 0; 3810 3752 ··· 3836 3778 3837 3779 entries_free = fec_enet_get_free_txdesc_num(txq); 3838 3780 if (entries_free < MAX_SKB_FRAGS + 1) { 3839 - netdev_err(fep->netdev, "NOT enough BD for SG!\n"); 3781 + netdev_err_once(fep->netdev, "NOT enough BD for SG!\n"); 3840 3782 return -EBUSY; 3841 3783 } 3842 3784 ··· 3869 3811 ebdp->cbd_esc = cpu_to_fec32(estatus); 3870 3812 } 3871 3813 3872 - txq->tx_skbuff[index] = NULL; 3814 + txq->tx_buf[index].type = FEC_TXBUF_T_XDP_NDO; 3815 + txq->tx_buf[index].xdp = frame; 3873 3816 3874 3817 /* Make sure the updates to rest of the descriptor are performed before 3875 3818 * transferring ownership. ··· 4075 4016 4076 4017 if (!(fep->quirks & FEC_QUIRK_SWAP_FRAME)) 4077 4018 ndev->xdp_features = NETDEV_XDP_ACT_BASIC | 4078 - NETDEV_XDP_ACT_REDIRECT | 4079 - NETDEV_XDP_ACT_NDO_XMIT; 4019 + NETDEV_XDP_ACT_REDIRECT; 4080 4020 4081 4021 fec_restart(ndev); 4082 4022
+1
drivers/net/ethernet/google/gve/gve.h
··· 964 964 /* exported by ethtool.c */ 965 965 extern const struct ethtool_ops gve_ethtool_ops; 966 966 /* needed by ethtool */ 967 + extern char gve_driver_name[]; 967 968 extern const char gve_version_str[]; 968 969 #endif /* _GVE_H_ */
+4 -1
drivers/net/ethernet/google/gve/gve_ethtool.c
··· 15 15 { 16 16 struct gve_priv *priv = netdev_priv(netdev); 17 17 18 - strscpy(info->driver, "gve", sizeof(info->driver)); 18 + strscpy(info->driver, gve_driver_name, sizeof(info->driver)); 19 19 strscpy(info->version, gve_version_str, sizeof(info->version)); 20 20 strscpy(info->bus_info, pci_name(priv->pdev), sizeof(info->bus_info)); 21 21 } ··· 590 590 err = gve_adminq_report_link_speed(priv); 591 591 592 592 cmd->base.speed = priv->link_speed; 593 + 594 + cmd->base.duplex = DUPLEX_FULL; 595 + 593 596 return err; 594 597 } 595 598
+6 -5
drivers/net/ethernet/google/gve/gve_main.c
··· 33 33 #define MIN_TX_TIMEOUT_GAP (1000 * 10) 34 34 #define DQO_TX_MAX 0x3FFFF 35 35 36 + char gve_driver_name[] = "gve"; 36 37 const char gve_version_str[] = GVE_VERSION; 37 38 static const char gve_version_prefix[] = GVE_VERSION_PREFIX; 38 39 ··· 2201 2200 if (err) 2202 2201 return err; 2203 2202 2204 - err = pci_request_regions(pdev, "gvnic-cfg"); 2203 + err = pci_request_regions(pdev, gve_driver_name); 2205 2204 if (err) 2206 2205 goto abort_with_enabled; 2207 2206 ··· 2394 2393 { } 2395 2394 }; 2396 2395 2397 - static struct pci_driver gvnic_driver = { 2398 - .name = "gvnic", 2396 + static struct pci_driver gve_driver = { 2397 + .name = gve_driver_name, 2399 2398 .id_table = gve_id_table, 2400 2399 .probe = gve_probe, 2401 2400 .remove = gve_remove, ··· 2406 2405 #endif 2407 2406 }; 2408 2407 2409 - module_pci_driver(gvnic_driver); 2408 + module_pci_driver(gve_driver); 2410 2409 2411 2410 MODULE_DEVICE_TABLE(pci, gve_id_table); 2412 2411 MODULE_AUTHOR("Google, Inc."); 2413 - MODULE_DESCRIPTION("gVNIC Driver"); 2412 + MODULE_DESCRIPTION("Google Virtual NIC Driver"); 2414 2413 MODULE_LICENSE("Dual MIT/GPL"); 2415 2414 MODULE_VERSION(GVE_VERSION);
+15 -8
drivers/net/ethernet/intel/ice/ice_main.c
··· 5739 5739 q_handle = vsi->tx_rings[queue_index]->q_handle; 5740 5740 tc = ice_dcb_get_tc(vsi, queue_index); 5741 5741 5742 + vsi = ice_locate_vsi_using_queue(vsi, queue_index); 5743 + if (!vsi) { 5744 + netdev_err(netdev, "Invalid VSI for given queue %d\n", 5745 + queue_index); 5746 + return -EINVAL; 5747 + } 5748 + 5742 5749 /* Set BW back to default, when user set maxrate to 0 */ 5743 5750 if (!maxrate) 5744 5751 status = ice_cfg_q_bw_dflt_lmt(vsi->port_info, vsi->idx, tc, ··· 7879 7872 ice_validate_mqprio_qopt(struct ice_vsi *vsi, 7880 7873 struct tc_mqprio_qopt_offload *mqprio_qopt) 7881 7874 { 7882 - u64 sum_max_rate = 0, sum_min_rate = 0; 7883 7875 int non_power_of_2_qcount = 0; 7884 7876 struct ice_pf *pf = vsi->back; 7885 7877 int max_rss_q_cnt = 0; 7878 + u64 sum_min_rate = 0; 7886 7879 struct device *dev; 7887 7880 int i, speed; 7888 7881 u8 num_tc; ··· 7898 7891 dev = ice_pf_to_dev(pf); 7899 7892 vsi->ch_rss_size = 0; 7900 7893 num_tc = mqprio_qopt->qopt.num_tc; 7894 + speed = ice_get_link_speed_kbps(vsi); 7901 7895 7902 7896 for (i = 0; num_tc; i++) { 7903 7897 int qcount = mqprio_qopt->qopt.count[i]; ··· 7939 7931 */ 7940 7932 max_rate = mqprio_qopt->max_rate[i]; 7941 7933 max_rate = div_u64(max_rate, ICE_BW_KBPS_DIVISOR); 7942 - sum_max_rate += max_rate; 7943 7934 7944 7935 /* min_rate is minimum guaranteed rate and it can't be zero */ 7945 7936 min_rate = mqprio_qopt->min_rate[i]; ··· 7948 7941 if (min_rate && min_rate < ICE_MIN_BW_LIMIT) { 7949 7942 dev_err(dev, "TC%d: min_rate(%llu Kbps) < %u Kbps\n", i, 7950 7943 min_rate, ICE_MIN_BW_LIMIT); 7944 + return -EINVAL; 7945 + } 7946 + 7947 + if (max_rate && max_rate > speed) { 7948 + dev_err(dev, "TC%d: max_rate(%llu Kbps) > link speed of %u Kbps\n", 7949 + i, max_rate, speed); 7951 7950 return -EINVAL; 7952 7951 } 7953 7952 ··· 7994 7981 (mqprio_qopt->qopt.offset[i] + mqprio_qopt->qopt.count[i])) 7995 7982 return -EINVAL; 7996 7983 7997 - speed = ice_get_link_speed_kbps(vsi); 7998 - if (sum_max_rate && sum_max_rate > (u64)speed) { 7999 - dev_err(dev, "Invalid max Tx rate(%llu) Kbps > speed(%u) Kbps specified\n", 8000 - sum_max_rate, speed); 8001 - return -EINVAL; 8002 - } 8003 7984 if (sum_min_rate && sum_min_rate > (u64)speed) { 8004 7985 dev_err(dev, "Invalid min Tx rate(%llu) Kbps > speed (%u) Kbps specified\n", 8005 7986 sum_min_rate, speed);
+11 -11
drivers/net/ethernet/intel/ice/ice_tc_lib.c
··· 750 750 /** 751 751 * ice_locate_vsi_using_queue - locate VSI using queue (forward to queue action) 752 752 * @vsi: Pointer to VSI 753 - * @tc_fltr: Pointer to tc_flower_filter 753 + * @queue: Queue index 754 754 * 755 - * Locate the VSI using specified queue. When ADQ is not enabled, always 756 - * return input VSI, otherwise locate corresponding VSI based on per channel 757 - * offset and qcount 755 + * Locate the VSI using specified "queue". When ADQ is not enabled, 756 + * always return input VSI, otherwise locate corresponding 757 + * VSI based on per channel "offset" and "qcount" 758 758 */ 759 - static struct ice_vsi * 760 - ice_locate_vsi_using_queue(struct ice_vsi *vsi, 761 - struct ice_tc_flower_fltr *tc_fltr) 759 + struct ice_vsi * 760 + ice_locate_vsi_using_queue(struct ice_vsi *vsi, int queue) 762 761 { 763 - int num_tc, tc, queue; 762 + int num_tc, tc; 764 763 765 764 /* if ADQ is not active, passed VSI is the candidate VSI */ 766 765 if (!ice_is_adq_active(vsi->back)) ··· 769 770 * upon queue number) 770 771 */ 771 772 num_tc = vsi->mqprio_qopt.qopt.num_tc; 772 - queue = tc_fltr->action.fwd.q.queue; 773 773 774 774 for (tc = 0; tc < num_tc; tc++) { 775 775 int qcount = vsi->mqprio_qopt.qopt.count[tc]; ··· 810 812 struct ice_pf *pf = vsi->back; 811 813 struct device *dev; 812 814 u32 tc_class; 815 + int q; 813 816 814 817 dev = ice_pf_to_dev(pf); 815 818 ··· 839 840 /* Determine destination VSI even though the action is 840 841 * FWD_TO_QUEUE, because QUEUE is associated with VSI 841 842 */ 842 - dest_vsi = tc_fltr->dest_vsi; 843 + q = tc_fltr->action.fwd.q.queue; 844 + dest_vsi = ice_locate_vsi_using_queue(vsi, q); 843 845 break; 844 846 default: 845 847 dev_err(dev, ··· 1716 1716 /* If ADQ is configured, and the queue belongs to ADQ VSI, then prepare 1717 1717 * ADQ switch filter 1718 1718 */ 1719 - ch_vsi = ice_locate_vsi_using_queue(vsi, fltr); 1719 + ch_vsi = ice_locate_vsi_using_queue(vsi, fltr->action.fwd.q.queue); 1720 1720 if (!ch_vsi) 1721 1721 return -EINVAL; 1722 1722 fltr->dest_vsi = ch_vsi;
+1
drivers/net/ethernet/intel/ice/ice_tc_lib.h
··· 204 204 return pf->num_dmac_chnl_fltrs; 205 205 } 206 206 207 + struct ice_vsi *ice_locate_vsi_using_queue(struct ice_vsi *vsi, int queue); 207 208 int 208 209 ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi, 209 210 struct flow_cls_offload *cls_flower);
+8 -1
drivers/net/ethernet/intel/igc/igc.h
··· 14 14 #include <linux/timecounter.h> 15 15 #include <linux/net_tstamp.h> 16 16 #include <linux/bitfield.h> 17 + #include <linux/hrtimer.h> 17 18 18 19 #include "igc_hw.h" 19 20 ··· 102 101 u32 start_time; 103 102 u32 end_time; 104 103 u32 max_sdu; 104 + bool oper_gate_closed; /* Operating gate. True if the TX Queue is closed */ 105 + bool admin_gate_closed; /* Future gate. True if the TX Queue will be closed */ 105 106 106 107 /* CBS parameters */ 107 108 bool cbs_enable; /* indicates if CBS is enabled */ ··· 163 160 struct timer_list watchdog_timer; 164 161 struct timer_list dma_err_timer; 165 162 struct timer_list phy_info_timer; 163 + struct hrtimer hrtimer; 166 164 167 165 u32 wol; 168 166 u32 en_mng_pt; ··· 188 184 u32 max_frame_size; 189 185 u32 min_frame_size; 190 186 187 + int tc_setup_type; 191 188 ktime_t base_time; 192 189 ktime_t cycle_time; 193 - bool qbv_enable; 190 + bool taprio_offload_enable; 194 191 u32 qbv_config_change_errors; 192 + bool qbv_transition; 193 + unsigned int qbv_count; 195 194 196 195 /* OS defined structs */ 197 196 struct pci_dev *pdev;
+2
drivers/net/ethernet/intel/igc/igc_ethtool.c
··· 1708 1708 /* twisted pair */ 1709 1709 cmd->base.port = PORT_TP; 1710 1710 cmd->base.phy_address = hw->phy.addr; 1711 + ethtool_link_ksettings_add_link_mode(cmd, supported, TP); 1712 + ethtool_link_ksettings_add_link_mode(cmd, advertising, TP); 1711 1713 1712 1714 /* advertising link modes */ 1713 1715 if (hw->phy.autoneg_advertised & ADVERTISE_10_HALF)
+68 -30
drivers/net/ethernet/intel/igc/igc_main.c
··· 711 711 /* disable the queue */ 712 712 wr32(IGC_TXDCTL(reg_idx), 0); 713 713 wrfl(); 714 - mdelay(10); 715 714 716 715 wr32(IGC_TDLEN(reg_idx), 717 716 ring->count * sizeof(union igc_adv_tx_desc)); ··· 1016 1017 ktime_t base_time = adapter->base_time; 1017 1018 ktime_t now = ktime_get_clocktai(); 1018 1019 ktime_t baset_est, end_of_cycle; 1019 - u32 launchtime; 1020 + s32 launchtime; 1020 1021 s64 n; 1021 1022 1022 1023 n = div64_s64(ktime_sub_ns(now, base_time), cycle_time); ··· 1029 1030 *first_flag = true; 1030 1031 ring->last_ff_cycle = baset_est; 1031 1032 1032 - if (ktime_compare(txtime, ring->last_tx_cycle) > 0) 1033 + if (ktime_compare(end_of_cycle, ring->last_tx_cycle) > 0) 1033 1034 *insert_empty = true; 1034 1035 } 1035 1036 } ··· 1572 1573 first->bytecount = skb->len; 1573 1574 first->gso_segs = 1; 1574 1575 1575 - if (tx_ring->max_sdu > 0) { 1576 - u32 max_sdu = 0; 1576 + if (adapter->qbv_transition || tx_ring->oper_gate_closed) 1577 + goto out_drop; 1577 1578 1578 - max_sdu = tx_ring->max_sdu + 1579 - (skb_vlan_tagged(first->skb) ? VLAN_HLEN : 0); 1580 - 1581 - if (first->bytecount > max_sdu) { 1582 - adapter->stats.txdrop++; 1583 - goto out_drop; 1584 - } 1579 + if (tx_ring->max_sdu > 0 && first->bytecount > tx_ring->max_sdu) { 1580 + adapter->stats.txdrop++; 1581 + goto out_drop; 1585 1582 } 1586 1583 1587 1584 if (unlikely(test_bit(IGC_RING_FLAG_TX_HWTSTAMP, &tx_ring->flags) && ··· 3007 3012 time_after(jiffies, tx_buffer->time_stamp + 3008 3013 (adapter->tx_timeout_factor * HZ)) && 3009 3014 !(rd32(IGC_STATUS) & IGC_STATUS_TXOFF) && 3010 - (rd32(IGC_TDH(tx_ring->reg_idx)) != 3011 - readl(tx_ring->tail))) { 3015 + (rd32(IGC_TDH(tx_ring->reg_idx)) != readl(tx_ring->tail)) && 3016 + !tx_ring->oper_gate_closed) { 3012 3017 /* detected Tx unit hang */ 3013 3018 netdev_err(tx_ring->netdev, 3014 3019 "Detected Tx Unit Hang\n" ··· 6097 6102 6098 6103 adapter->base_time = 0; 6099 6104 adapter->cycle_time = NSEC_PER_SEC; 6105 + adapter->taprio_offload_enable = false; 6100 6106 adapter->qbv_config_change_errors = 0; 6107 + adapter->qbv_transition = false; 6108 + adapter->qbv_count = 0; 6101 6109 6102 6110 for (i = 0; i < adapter->num_tx_queues; i++) { 6103 6111 struct igc_ring *ring = adapter->tx_ring[i]; ··· 6108 6110 ring->start_time = 0; 6109 6111 ring->end_time = NSEC_PER_SEC; 6110 6112 ring->max_sdu = 0; 6113 + ring->oper_gate_closed = false; 6114 + ring->admin_gate_closed = false; 6111 6115 } 6112 6116 6113 6117 return 0; ··· 6121 6121 bool queue_configured[IGC_MAX_TX_QUEUES] = { }; 6122 6122 struct igc_hw *hw = &adapter->hw; 6123 6123 u32 start_time = 0, end_time = 0; 6124 + struct timespec64 now; 6124 6125 size_t n; 6125 6126 int i; 6126 6127 6127 - switch (qopt->cmd) { 6128 - case TAPRIO_CMD_REPLACE: 6129 - adapter->qbv_enable = true; 6130 - break; 6131 - case TAPRIO_CMD_DESTROY: 6132 - adapter->qbv_enable = false; 6133 - break; 6134 - default: 6135 - return -EOPNOTSUPP; 6136 - } 6137 - 6138 - if (!adapter->qbv_enable) 6128 + if (qopt->cmd == TAPRIO_CMD_DESTROY) 6139 6129 return igc_tsn_clear_schedule(adapter); 6130 + 6131 + if (qopt->cmd != TAPRIO_CMD_REPLACE) 6132 + return -EOPNOTSUPP; 6140 6133 6141 6134 if (qopt->base_time < 0) 6142 6135 return -ERANGE; 6143 6136 6144 - if (igc_is_device_id_i225(hw) && adapter->base_time) 6137 + if (igc_is_device_id_i225(hw) && adapter->taprio_offload_enable) 6145 6138 return -EALREADY; 6146 6139 6147 6140 if (!validate_schedule(adapter, qopt)) ··· 6142 6149 6143 6150 adapter->cycle_time = qopt->cycle_time; 6144 6151 adapter->base_time = qopt->base_time; 6152 + adapter->taprio_offload_enable = true; 6153 + 6154 + igc_ptp_read(adapter, &now); 6145 6155 6146 6156 for (n = 0; n < qopt->num_entries; n++) { 6147 6157 struct tc_taprio_sched_entry *e = &qopt->entries[n]; ··· 6180 6184 ring->start_time = start_time; 6181 6185 ring->end_time = end_time; 6182 6186 6183 - queue_configured[i] = true; 6187 + if (ring->start_time >= adapter->cycle_time) 6188 + queue_configured[i] = false; 6189 + else 6190 + queue_configured[i] = true; 6184 6191 } 6185 6192 6186 6193 start_time += e->interval; ··· 6193 6194 * If not, set the start and end time to be end time. 6194 6195 */ 6195 6196 for (i = 0; i < adapter->num_tx_queues; i++) { 6197 + struct igc_ring *ring = adapter->tx_ring[i]; 6198 + 6199 + if (!is_base_time_past(qopt->base_time, &now)) { 6200 + ring->admin_gate_closed = false; 6201 + } else { 6202 + ring->oper_gate_closed = false; 6203 + ring->admin_gate_closed = false; 6204 + } 6205 + 6196 6206 if (!queue_configured[i]) { 6197 - struct igc_ring *ring = adapter->tx_ring[i]; 6207 + if (!is_base_time_past(qopt->base_time, &now)) 6208 + ring->admin_gate_closed = true; 6209 + else 6210 + ring->oper_gate_closed = true; 6198 6211 6199 6212 ring->start_time = end_time; 6200 6213 ring->end_time = end_time; ··· 6218 6207 struct net_device *dev = adapter->netdev; 6219 6208 6220 6209 if (qopt->max_sdu[i]) 6221 - ring->max_sdu = qopt->max_sdu[i] + dev->hard_header_len; 6210 + ring->max_sdu = qopt->max_sdu[i] + dev->hard_header_len - ETH_TLEN; 6222 6211 else 6223 6212 ring->max_sdu = 0; 6224 6213 } ··· 6337 6326 void *type_data) 6338 6327 { 6339 6328 struct igc_adapter *adapter = netdev_priv(dev); 6329 + 6330 + adapter->tc_setup_type = type; 6340 6331 6341 6332 switch (type) { 6342 6333 case TC_QUERY_CAPS: ··· 6587 6574 .xmo_rx_timestamp = igc_xdp_rx_timestamp, 6588 6575 }; 6589 6576 6577 + static enum hrtimer_restart igc_qbv_scheduling_timer(struct hrtimer *timer) 6578 + { 6579 + struct igc_adapter *adapter = container_of(timer, struct igc_adapter, 6580 + hrtimer); 6581 + unsigned int i; 6582 + 6583 + adapter->qbv_transition = true; 6584 + for (i = 0; i < adapter->num_tx_queues; i++) { 6585 + struct igc_ring *tx_ring = adapter->tx_ring[i]; 6586 + 6587 + if (tx_ring->admin_gate_closed) { 6588 + tx_ring->admin_gate_closed = false; 6589 + tx_ring->oper_gate_closed = true; 6590 + } else { 6591 + tx_ring->oper_gate_closed = false; 6592 + } 6593 + } 6594 + adapter->qbv_transition = false; 6595 + return HRTIMER_NORESTART; 6596 + } 6597 + 6590 6598 /** 6591 6599 * igc_probe - Device Initialization Routine 6592 6600 * @pdev: PCI device information struct ··· 6786 6752 INIT_WORK(&adapter->reset_task, igc_reset_task); 6787 6753 INIT_WORK(&adapter->watchdog_task, igc_watchdog_task); 6788 6754 6755 + hrtimer_init(&adapter->hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 6756 + adapter->hrtimer.function = &igc_qbv_scheduling_timer; 6757 + 6789 6758 /* Initialize link properties that are user-changeable */ 6790 6759 adapter->fc_autoneg = true; 6791 6760 hw->mac.autoneg = true; ··· 6892 6855 6893 6856 cancel_work_sync(&adapter->reset_task); 6894 6857 cancel_work_sync(&adapter->watchdog_task); 6858 + hrtimer_cancel(&adapter->hrtimer); 6895 6859 6896 6860 /* Release control of h/w to f/w. If f/w is AMT enabled, this 6897 6861 * would have already happened in close and is redundant.
+22 -3
drivers/net/ethernet/intel/igc/igc_ptp.c
··· 356 356 tsim &= ~IGC_TSICR_TT0; 357 357 } 358 358 if (on) { 359 + struct timespec64 safe_start; 359 360 int i = rq->perout.index; 360 361 361 362 igc_pin_perout(igc, i, pin, use_freq); 362 - igc->perout[i].start.tv_sec = rq->perout.start.sec; 363 + igc_ptp_read(igc, &safe_start); 364 + 365 + /* PPS output start time is triggered by Target time(TT) 366 + * register. Programming any past time value into TT 367 + * register will cause PPS to never start. Need to make 368 + * sure we program the TT register a time ahead in 369 + * future. There isn't a stringent need to fire PPS out 370 + * right away. Adding +2 seconds should take care of 371 + * corner cases. Let's say if the SYSTIML is close to 372 + * wrap up and the timer keeps ticking as we program the 373 + * register, adding +2seconds is safe bet. 374 + */ 375 + safe_start.tv_sec += 2; 376 + 377 + if (rq->perout.start.sec < safe_start.tv_sec) 378 + igc->perout[i].start.tv_sec = safe_start.tv_sec; 379 + else 380 + igc->perout[i].start.tv_sec = rq->perout.start.sec; 363 381 igc->perout[i].start.tv_nsec = rq->perout.start.nsec; 364 382 igc->perout[i].period.tv_sec = ts.tv_sec; 365 383 igc->perout[i].period.tv_nsec = ts.tv_nsec; 366 - wr32(trgttimh, rq->perout.start.sec); 384 + wr32(trgttimh, (u32)igc->perout[i].start.tv_sec); 367 385 /* For now, always select timer 0 as source. */ 368 - wr32(trgttiml, rq->perout.start.nsec | IGC_TT_IO_TIMER_SEL_SYSTIM0); 386 + wr32(trgttiml, (u32)(igc->perout[i].start.tv_nsec | 387 + IGC_TT_IO_TIMER_SEL_SYSTIM0)); 369 388 if (use_freq) 370 389 wr32(freqout, ns); 371 390 tsauxc |= tsauxc_mask;
+51 -17
drivers/net/ethernet/intel/igc/igc_tsn.c
··· 37 37 { 38 38 unsigned int new_flags = adapter->flags & ~IGC_FLAG_TSN_ANY_ENABLED; 39 39 40 - if (adapter->qbv_enable) 40 + if (adapter->taprio_offload_enable) 41 41 new_flags |= IGC_FLAG_TSN_QBV_ENABLED; 42 42 43 43 if (is_any_launchtime(adapter)) ··· 114 114 static int igc_tsn_enable_offload(struct igc_adapter *adapter) 115 115 { 116 116 struct igc_hw *hw = &adapter->hw; 117 - bool tsn_mode_reconfig = false; 118 117 u32 tqavctrl, baset_l, baset_h; 119 118 u32 sec, nsec, cycle; 120 119 ktime_t base_time, systim; ··· 132 133 wr32(IGC_STQT(i), ring->start_time); 133 134 wr32(IGC_ENDQT(i), ring->end_time); 134 135 135 - txqctl |= IGC_TXQCTL_STRICT_CYCLE | 136 - IGC_TXQCTL_STRICT_END; 136 + if (adapter->taprio_offload_enable) { 137 + /* If taprio_offload_enable is set we are in "taprio" 138 + * mode and we need to be strict about the 139 + * cycles: only transmit a packet if it can be 140 + * completed during that cycle. 141 + * 142 + * If taprio_offload_enable is NOT true when 143 + * enabling TSN offload, the cycle should have 144 + * no external effects, but is only used internally 145 + * to adapt the base time register after a second 146 + * has passed. 147 + * 148 + * Enabling strict mode in this case would 149 + * unnecessarily prevent the transmission of 150 + * certain packets (i.e. at the boundary of a 151 + * second) and thus interfere with the launchtime 152 + * feature that promises transmission at a 153 + * certain point in time. 154 + */ 155 + txqctl |= IGC_TXQCTL_STRICT_CYCLE | 156 + IGC_TXQCTL_STRICT_END; 157 + } 137 158 138 159 if (ring->launchtime_enable) 139 160 txqctl |= IGC_TXQCTL_QUEUE_MODE_LAUNCHT; ··· 247 228 248 229 tqavctrl = rd32(IGC_TQAVCTRL) & ~IGC_TQAVCTRL_FUTSCDDIS; 249 230 250 - if (tqavctrl & IGC_TQAVCTRL_TRANSMIT_MODE_TSN) 251 - tsn_mode_reconfig = true; 252 - 253 231 tqavctrl |= IGC_TQAVCTRL_TRANSMIT_MODE_TSN | IGC_TQAVCTRL_ENHANCED_QAV; 232 + 233 + adapter->qbv_count++; 254 234 255 235 cycle = adapter->cycle_time; 256 236 base_time = adapter->base_time; ··· 267 249 * Gate Control List (GCL) is running. 268 250 */ 269 251 if ((rd32(IGC_BASET_H) || rd32(IGC_BASET_L)) && 270 - tsn_mode_reconfig) 252 + (adapter->tc_setup_type == TC_SETUP_QDISC_TAPRIO) && 253 + (adapter->qbv_count > 1)) 271 254 adapter->qbv_config_change_errors++; 272 255 } else { 273 - /* According to datasheet section 7.5.2.9.3.3, FutScdDis bit 274 - * has to be configured before the cycle time and base time. 275 - * Tx won't hang if there is a GCL is already running, 276 - * so in this case we don't need to set FutScdDis. 277 - */ 278 - if (igc_is_device_id_i226(hw) && 279 - !(rd32(IGC_BASET_H) || rd32(IGC_BASET_L))) 280 - tqavctrl |= IGC_TQAVCTRL_FUTSCDDIS; 256 + if (igc_is_device_id_i226(hw)) { 257 + ktime_t adjust_time, expires_time; 258 + 259 + /* According to datasheet section 7.5.2.9.3.3, FutScdDis bit 260 + * has to be configured before the cycle time and base time. 261 + * Tx won't hang if a GCL is already running, 262 + * so in this case we don't need to set FutScdDis. 263 + */ 264 + if (!(rd32(IGC_BASET_H) || rd32(IGC_BASET_L))) 265 + tqavctrl |= IGC_TQAVCTRL_FUTSCDDIS; 266 + 267 + nsec = rd32(IGC_SYSTIML); 268 + sec = rd32(IGC_SYSTIMH); 269 + systim = ktime_set(sec, nsec); 270 + 271 + adjust_time = adapter->base_time; 272 + expires_time = ktime_sub_ns(adjust_time, systim); 273 + hrtimer_start(&adapter->hrtimer, expires_time, HRTIMER_MODE_REL); 274 + } 281 275 } 282 276 283 277 wr32(IGC_TQAVCTRL, tqavctrl); ··· 335 305 { 336 306 struct igc_hw *hw = &adapter->hw; 337 307 338 - if (netif_running(adapter->netdev) && igc_is_device_id_i225(hw)) { 308 + /* Per I225/6 HW Design Section 7.5.2.1, transmit mode 309 + * cannot be changed dynamically. Require reset the adapter. 310 + */ 311 + if (netif_running(adapter->netdev) && 312 + (igc_is_device_id_i225(hw) || !adapter->qbv_count)) { 339 313 schedule_work(&adapter->reset_task); 340 314 return 0; 341 315 }
+2 -2
drivers/net/ethernet/marvell/mvneta.c
··· 1511 1511 */ 1512 1512 if (txq_number == 1) 1513 1513 txq_map = (cpu == pp->rxq_def) ? 1514 - MVNETA_CPU_TXQ_ACCESS(1) : 0; 1514 + MVNETA_CPU_TXQ_ACCESS(0) : 0; 1515 1515 1516 1516 } else { 1517 1517 txq_map = MVNETA_CPU_TXQ_ACCESS_ALL_MASK; ··· 4356 4356 */ 4357 4357 if (txq_number == 1) 4358 4358 txq_map = (cpu == elected_cpu) ? 4359 - MVNETA_CPU_TXQ_ACCESS(1) : 0; 4359 + MVNETA_CPU_TXQ_ACCESS(0) : 0; 4360 4360 else 4361 4361 txq_map = mvreg_read(pp, MVNETA_CPU_MAP(cpu)) & 4362 4362 MVNETA_CPU_TXQ_ACCESS_ALL_MASK;
+9 -10
drivers/net/ethernet/marvell/octeontx2/af/ptp.c
··· 208 208 /* Check driver is bound to PTP block */ 209 209 if (!ptp) 210 210 ptp = ERR_PTR(-EPROBE_DEFER); 211 - else 211 + else if (!IS_ERR(ptp)) 212 212 pci_dev_get(ptp->pdev); 213 213 214 214 return ptp; ··· 388 388 static int ptp_probe(struct pci_dev *pdev, 389 389 const struct pci_device_id *ent) 390 390 { 391 - struct device *dev = &pdev->dev; 392 391 struct ptp *ptp; 393 392 int err; 394 393 395 - ptp = devm_kzalloc(dev, sizeof(*ptp), GFP_KERNEL); 394 + ptp = kzalloc(sizeof(*ptp), GFP_KERNEL); 396 395 if (!ptp) { 397 396 err = -ENOMEM; 398 397 goto error; ··· 427 428 return 0; 428 429 429 430 error_free: 430 - devm_kfree(dev, ptp); 431 + kfree(ptp); 431 432 432 433 error: 433 434 /* For `ptp_get()` we need to differentiate between the case 434 435 * when the core has not tried to probe this device and the case when 435 - * the probe failed. In the later case we pretend that the 436 - * initialization was successful and keep the error in 436 + * the probe failed. In the later case we keep the error in 437 437 * `dev->driver_data`. 438 438 */ 439 439 pci_set_drvdata(pdev, ERR_PTR(err)); 440 440 if (!first_ptp_block) 441 441 first_ptp_block = ERR_PTR(err); 442 442 443 - return 0; 443 + return err; 444 444 } 445 445 446 446 static void ptp_remove(struct pci_dev *pdev) ··· 447 449 struct ptp *ptp = pci_get_drvdata(pdev); 448 450 u64 clock_cfg; 449 451 450 - if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer)) 451 - hrtimer_cancel(&ptp->hrtimer); 452 - 453 452 if (IS_ERR_OR_NULL(ptp)) 454 453 return; 454 + 455 + if (cn10k_ptp_errata(ptp) && hrtimer_active(&ptp->hrtimer)) 456 + hrtimer_cancel(&ptp->hrtimer); 455 457 456 458 /* Disable PTP clock */ 457 459 clock_cfg = readq(ptp->reg_base + PTP_CLOCK_CFG); 458 460 clock_cfg &= ~PTP_CLOCK_CFG_PTP_EN; 459 461 writeq(clock_cfg, ptp->reg_base + PTP_CLOCK_CFG); 462 + kfree(ptp); 460 463 } 461 464 462 465 static const struct pci_device_id ptp_id_table[] = {
+1 -1
drivers/net/ethernet/marvell/octeontx2/af/rvu.c
··· 3252 3252 rvu->ptp = ptp_get(); 3253 3253 if (IS_ERR(rvu->ptp)) { 3254 3254 err = PTR_ERR(rvu->ptp); 3255 - if (err == -EPROBE_DEFER) 3255 + if (err) 3256 3256 goto err_release_regions; 3257 3257 rvu->ptp = NULL; 3258 3258 }
+2 -9
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c
··· 4069 4069 } 4070 4070 4071 4071 /* install/uninstall promisc entry */ 4072 - if (promisc) { 4072 + if (promisc) 4073 4073 rvu_npc_install_promisc_entry(rvu, pcifunc, nixlf, 4074 4074 pfvf->rx_chan_base, 4075 4075 pfvf->rx_chan_cnt); 4076 - 4077 - if (rvu_npc_exact_has_match_table(rvu)) 4078 - rvu_npc_exact_promisc_enable(rvu, pcifunc); 4079 - } else { 4076 + else 4080 4077 if (!nix_rx_multicast) 4081 4078 rvu_npc_enable_promisc_entry(rvu, pcifunc, nixlf, false); 4082 - 4083 - if (rvu_npc_exact_has_match_table(rvu)) 4084 - rvu_npc_exact_promisc_disable(rvu, pcifunc); 4085 - } 4086 4079 4087 4080 return 0; 4088 4081 }
+21 -2
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_hash.c
··· 1164 1164 { 1165 1165 struct npc_exact_table *table; 1166 1166 u16 *cnt, old_cnt; 1167 + bool promisc; 1167 1168 1168 1169 table = rvu->hw->table; 1170 + promisc = table->promisc_mode[drop_mcam_idx]; 1169 1171 1170 1172 cnt = &table->cnt_cmd_rules[drop_mcam_idx]; 1171 1173 old_cnt = *cnt; ··· 1179 1177 1180 1178 *enable_or_disable_cam = false; 1181 1179 1182 - /* If all rules are deleted, disable cam */ 1180 + if (promisc) 1181 + goto done; 1182 + 1183 + /* If all rules are deleted and not already in promisc mode; 1184 + * disable cam 1185 + */ 1183 1186 if (!*cnt && val < 0) { 1184 1187 *enable_or_disable_cam = true; 1185 1188 goto done; 1186 1189 } 1187 1190 1188 - /* If rule got added, enable cam */ 1191 + /* If rule got added and not already in promisc mode; enable cam */ 1189 1192 if (!old_cnt && val > 0) { 1190 1193 *enable_or_disable_cam = true; 1191 1194 goto done; ··· 1469 1462 *promisc = false; 1470 1463 mutex_unlock(&table->lock); 1471 1464 1465 + /* Enable drop rule */ 1466 + rvu_npc_enable_mcam_by_entry_index(rvu, drop_mcam_idx, NIX_INTF_RX, 1467 + true); 1468 + 1469 + dev_dbg(rvu->dev, "%s: disabled promisc mode (cgx=%d lmac=%d)\n", 1470 + __func__, cgx_id, lmac_id); 1472 1471 return 0; 1473 1472 } 1474 1473 ··· 1516 1503 *promisc = true; 1517 1504 mutex_unlock(&table->lock); 1518 1505 1506 + /* disable drop rule */ 1507 + rvu_npc_enable_mcam_by_entry_index(rvu, drop_mcam_idx, NIX_INTF_RX, 1508 + false); 1509 + 1510 + dev_dbg(rvu->dev, "%s: Enabled promisc mode (cgx=%d lmac=%d)\n", 1511 + __func__, cgx_id, lmac_id); 1519 1512 return 0; 1520 1513 } 1521 1514
+8
drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
··· 872 872 return -EINVAL; 873 873 874 874 vlan_etype = be16_to_cpu(fsp->h_ext.vlan_etype); 875 + 876 + /* Drop rule with vlan_etype == 802.1Q 877 + * and vlan_id == 0 is not supported 878 + */ 879 + if (vlan_etype == ETH_P_8021Q && !fsp->m_ext.vlan_tci && 880 + fsp->ring_cookie == RX_CLS_FLOW_DISC) 881 + return -EINVAL; 882 + 875 883 /* Only ETH_P_8021Q and ETH_P_802AD types supported */ 876 884 if (vlan_etype != ETH_P_8021Q && 877 885 vlan_etype != ETH_P_8021AD)
+15
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c
··· 597 597 return -EOPNOTSUPP; 598 598 } 599 599 600 + if (!match.mask->vlan_id) { 601 + struct flow_action_entry *act; 602 + int i; 603 + 604 + flow_action_for_each(i, act, &rule->action) { 605 + if (act->id == FLOW_ACTION_DROP) { 606 + netdev_err(nic->netdev, 607 + "vlan tpid 0x%x with vlan_id %d is not supported for DROP rule.\n", 608 + ntohs(match.key->vlan_tpid), 609 + match.key->vlan_id); 610 + return -EOPNOTSUPP; 611 + } 612 + } 613 + } 614 + 600 615 if (match.mask->vlan_id || 601 616 match.mask->vlan_dei || 602 617 match.mask->vlan_priority) {
+3 -3
drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
··· 594 594 595 595 err = fs_any_create_table(fs); 596 596 if (err) 597 - return err; 597 + goto err_free_any; 598 598 599 599 err = fs_any_enable(fs); 600 600 if (err) ··· 606 606 607 607 err_destroy_table: 608 608 fs_any_destroy_table(fs_any); 609 - 610 - kfree(fs_any); 609 + err_free_any: 611 610 mlx5e_fs_set_any(fs, NULL); 611 + kfree(fs_any); 612 612 return err; 613 613 }
+4 -2
drivers/net/ethernet/mellanox/mlx5/core/en/ptp.c
··· 729 729 730 730 c = kvzalloc_node(sizeof(*c), GFP_KERNEL, dev_to_node(mlx5_core_dma_dev(mdev))); 731 731 cparams = kvzalloc(sizeof(*cparams), GFP_KERNEL); 732 - if (!c || !cparams) 733 - return -ENOMEM; 732 + if (!c || !cparams) { 733 + err = -ENOMEM; 734 + goto err_free; 735 + } 734 736 735 737 c->priv = priv; 736 738 c->mdev = priv->mdev;
+11 -3
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
··· 1545 1545 1546 1546 attr->ct_attr.ct_action |= act->ct.action; /* So we can have clear + ct */ 1547 1547 attr->ct_attr.zone = act->ct.zone; 1548 - attr->ct_attr.nf_ft = act->ct.flow_table; 1548 + if (!(act->ct.action & TCA_CT_ACT_CLEAR)) 1549 + attr->ct_attr.nf_ft = act->ct.flow_table; 1549 1550 attr->ct_attr.act_miss_cookie = act->miss_cookie; 1550 1551 1551 1552 return 0; ··· 1991 1990 if (!priv) 1992 1991 return -EOPNOTSUPP; 1993 1992 1993 + if (attr->ct_attr.offloaded) 1994 + return 0; 1995 + 1994 1996 if (attr->ct_attr.ct_action & TCA_CT_ACT_CLEAR) { 1995 1997 err = mlx5_tc_ct_entry_set_registers(priv, &attr->parse_attr->mod_hdr_acts, 1996 1998 0, 0, 0, 0); ··· 2003 1999 attr->action |= MLX5_FLOW_CONTEXT_ACTION_MOD_HDR; 2004 2000 } 2005 2001 2006 - if (!attr->ct_attr.nf_ft) /* means only ct clear action, and not ct_clear,ct() */ 2002 + if (!attr->ct_attr.nf_ft) { /* means only ct clear action, and not ct_clear,ct() */ 2003 + attr->ct_attr.offloaded = true; 2007 2004 return 0; 2005 + } 2008 2006 2009 2007 mutex_lock(&priv->control_lock); 2010 2008 err = __mlx5_tc_ct_flow_offload(priv, attr); 2009 + if (!err) 2010 + attr->ct_attr.offloaded = true; 2011 2011 mutex_unlock(&priv->control_lock); 2012 2012 2013 2013 return err; ··· 2029 2021 mlx5_tc_ct_delete_flow(struct mlx5_tc_ct_priv *priv, 2030 2022 struct mlx5_flow_attr *attr) 2031 2023 { 2032 - if (!attr->ct_attr.ft) /* no ct action, return */ 2024 + if (!attr->ct_attr.offloaded) /* no ct action, return */ 2033 2025 return; 2034 2026 if (!attr->ct_attr.nf_ft) /* means only ct clear action, and not ct_clear,ct() */ 2035 2027 return;
+1
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.h
··· 29 29 u32 ct_labels_id; 30 30 u32 act_miss_mapping; 31 31 u64 act_miss_cookie; 32 + bool offloaded; 32 33 struct mlx5_ct_ft *ft; 33 34 }; 34 35
+1 -2
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
··· 662 662 /* No need to check ((page->pp_magic & ~0x3UL) == PP_SIGNATURE) 663 663 * as we know this is a page_pool page. 664 664 */ 665 - page_pool_put_defragged_page(page->pp, 666 - page, -1, true); 665 + page_pool_recycle_direct(page->pp, page); 667 666 } while (++n < num); 668 667 669 668 break;
+1
drivers/net/ethernet/mellanox/mlx5/core/en_accel/fs_tcp.c
··· 190 190 in = kvzalloc(inlen, GFP_KERNEL); 191 191 if (!in || !ft->g) { 192 192 kfree(ft->g); 193 + ft->g = NULL; 193 194 kvfree(in); 194 195 return -ENOMEM; 195 196 }
+22 -22
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
··· 390 390 { 391 391 struct mlx5e_wqe_frag_info *wi = get_frag(rq, ix); 392 392 393 - if (rq->xsk_pool) 393 + if (rq->xsk_pool) { 394 394 mlx5e_xsk_free_rx_wqe(wi); 395 - else 395 + } else { 396 396 mlx5e_free_rx_wqe(rq, wi); 397 + 398 + /* Avoid a second release of the wqe pages: dealloc is called 399 + * for the same missing wqes on regular RQ flush and on regular 400 + * RQ close. This happens when XSK RQs come into play. 401 + */ 402 + for (int i = 0; i < rq->wqe.info.num_frags; i++, wi++) 403 + wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE); 404 + } 397 405 } 398 406 399 407 static void mlx5e_xsk_free_rx_wqes(struct mlx5e_rq *rq, u16 ix, int wqe_bulk) ··· 1751 1743 1752 1744 prog = rcu_dereference(rq->xdp_prog); 1753 1745 if (prog && mlx5e_xdp_handle(rq, prog, &mxbuf)) { 1754 - if (test_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) { 1746 + if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) { 1755 1747 struct mlx5e_wqe_frag_info *pwi; 1756 1748 1757 1749 for (pwi = head_wi; pwi < wi; pwi++) 1758 - pwi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE); 1750 + pwi->frag_page->frags++; 1759 1751 } 1760 1752 return NULL; /* page/packet was consumed by XDP */ 1761 1753 } ··· 1825 1817 rq, wi, cqe, cqe_bcnt); 1826 1818 if (!skb) { 1827 1819 /* probably for XDP */ 1828 - if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) { 1829 - /* do not return page to cache, 1830 - * it will be returned on XDP_TX completion. 1831 - */ 1832 - wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE); 1833 - } 1820 + if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) 1821 + wi->frag_page->frags++; 1834 1822 goto wq_cyc_pop; 1835 1823 } 1836 1824 ··· 1872 1868 rq, wi, cqe, cqe_bcnt); 1873 1869 if (!skb) { 1874 1870 /* probably for XDP */ 1875 - if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) { 1876 - /* do not return page to cache, 1877 - * it will be returned on XDP_TX completion. 1878 - */ 1879 - wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE); 1880 - } 1871 + if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) 1872 + wi->frag_page->frags++; 1881 1873 goto wq_cyc_pop; 1882 1874 } 1883 1875 ··· 2052 2052 if (prog) { 2053 2053 if (mlx5e_xdp_handle(rq, prog, &mxbuf)) { 2054 2054 if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) { 2055 - int i; 2055 + struct mlx5e_frag_page *pfp; 2056 2056 2057 - for (i = 0; i < sinfo->nr_frags; i++) 2058 - /* non-atomic */ 2059 - __set_bit(page_idx + i, wi->skip_release_bitmap); 2060 - return NULL; 2057 + for (pfp = head_page; pfp < frag_page; pfp++) 2058 + pfp->frags++; 2059 + 2060 + wi->linear_page.frags++; 2061 2061 } 2062 2062 mlx5e_page_release_fragmented(rq, &wi->linear_page); 2063 2063 return NULL; /* page/packet was consumed by XDP */ ··· 2155 2155 cqe_bcnt, &mxbuf); 2156 2156 if (mlx5e_xdp_handle(rq, prog, &mxbuf)) { 2157 2157 if (__test_and_clear_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags)) 2158 - __set_bit(page_idx, wi->skip_release_bitmap); /* non-atomic */ 2158 + frag_page->frags++; 2159 2159 return NULL; /* page/packet was consumed by XDP */ 2160 2160 } 2161 2161
+3 -3
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
··· 1639 1639 uplink_priv = &rpriv->uplink_priv; 1640 1640 1641 1641 mutex_lock(&uplink_priv->unready_flows_lock); 1642 - unready_flow_del(flow); 1642 + if (flow_flag_test(flow, NOT_READY)) 1643 + unready_flow_del(flow); 1643 1644 mutex_unlock(&uplink_priv->unready_flows_lock); 1644 1645 } 1645 1646 ··· 1933 1932 esw_attr = attr->esw_attr; 1934 1933 mlx5e_put_flow_tunnel_id(flow); 1935 1934 1936 - if (flow_flag_test(flow, NOT_READY)) 1937 - remove_unready_flow(flow); 1935 + remove_unready_flow(flow); 1938 1936 1939 1937 if (mlx5e_is_offloaded_flow(flow)) { 1940 1938 if (flow_flag_test(flow, SLOW))
+3
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 807 807 hca_caps = MLX5_ADDR_OF(query_hca_cap_out, query_ctx, capability); 808 808 vport->info.roce_enabled = MLX5_GET(cmd_hca_cap, hca_caps, roce); 809 809 810 + if (!MLX5_CAP_GEN_MAX(esw->dev, hca_cap_2)) 811 + goto out_free; 812 + 810 813 memset(query_ctx, 0, query_out_sz); 811 814 err = mlx5_vport_get_other_func_cap(esw->dev, vport->vport, query_ctx, 812 815 MLX5_CAP_GENERAL_2);
+12 -7
drivers/net/ethernet/mellanox/mlx5/core/thermal.c
··· 68 68 69 69 int mlx5_thermal_init(struct mlx5_core_dev *mdev) 70 70 { 71 + char data[THERMAL_NAME_LENGTH]; 71 72 struct mlx5_thermal *thermal; 72 - struct thermal_zone_device *tzd; 73 - const char *data = "mlx5"; 73 + int err; 74 74 75 - tzd = thermal_zone_get_zone_by_name(data); 76 - if (!IS_ERR(tzd)) 75 + if (!mlx5_core_is_pf(mdev) && !mlx5_core_is_ecpf(mdev)) 77 76 return 0; 77 + 78 + err = snprintf(data, sizeof(data), "mlx5_%s", dev_name(mdev->device)); 79 + if (err < 0 || err >= sizeof(data)) { 80 + mlx5_core_err(mdev, "Failed to setup thermal zone name, %d\n", err); 81 + return -EINVAL; 82 + } 78 83 79 84 thermal = kzalloc(sizeof(*thermal), GFP_KERNEL); 80 85 if (!thermal) ··· 94 89 &mlx5_thermal_ops, 95 90 NULL, 0, MLX5_THERMAL_POLL_INT_MSEC); 96 91 if (IS_ERR(thermal->tzdev)) { 97 - dev_err(mdev->device, "Failed to register thermal zone device (%s) %ld\n", 98 - data, PTR_ERR(thermal->tzdev)); 92 + err = PTR_ERR(thermal->tzdev); 93 + mlx5_core_err(mdev, "Failed to register thermal zone device (%s) %d\n", data, err); 99 94 kfree(thermal); 100 - return -EINVAL; 95 + return err; 101 96 } 102 97 103 98 mdev->thermal = thermal;
+1 -1
drivers/net/ethernet/microchip/Kconfig
··· 46 46 tristate "LAN743x support" 47 47 depends on PCI 48 48 depends on PTP_1588_CLOCK_OPTIONAL 49 - select PHYLIB 49 + select FIXED_PHY 50 50 select CRC16 51 51 select CRC32 52 52 help
-1
drivers/net/ethernet/mscc/ocelot.c
··· 2927 2927 2928 2928 mutex_init(&ocelot->mact_lock); 2929 2929 mutex_init(&ocelot->fwd_domain_lock); 2930 - mutex_init(&ocelot->tas_lock); 2931 2930 spin_lock_init(&ocelot->ptp_clock_lock); 2932 2931 spin_lock_init(&ocelot->ts_id_lock); 2933 2932
+7 -7
drivers/net/ethernet/mscc/ocelot_mm.c
··· 67 67 val = mm->preemptible_tcs; 68 68 69 69 /* Cut through switching doesn't work for preemptible priorities, 70 - * so first make sure it is disabled. 70 + * so first make sure it is disabled. Also, changing the preemptible 71 + * TCs affects the oversized frame dropping logic, so that needs to be 72 + * re-triggered. And since tas_guard_bands_update() also implicitly 73 + * calls cut_through_fwd(), we don't need to explicitly call it. 71 74 */ 72 75 mm->active_preemptible_tcs = val; 73 - ocelot->ops->cut_through_fwd(ocelot); 76 + ocelot->ops->tas_guard_bands_update(ocelot, port); 74 77 75 78 dev_dbg(ocelot->dev, 76 79 "port %d %s/%s, MM TX %s, preemptible TCs 0x%x, active 0x%x\n", ··· 92 89 { 93 90 struct ocelot_mm_state *mm = &ocelot->mm[port]; 94 91 95 - mutex_lock(&ocelot->fwd_domain_lock); 92 + lockdep_assert_held(&ocelot->fwd_domain_lock); 96 93 97 94 if (mm->preemptible_tcs == preemptible_tcs) 98 - goto out_unlock; 95 + return; 99 96 100 97 mm->preemptible_tcs = preemptible_tcs; 101 98 102 99 ocelot_port_update_active_preemptible_tcs(ocelot, port); 103 - 104 - out_unlock: 105 - mutex_unlock(&ocelot->fwd_domain_lock); 106 100 } 107 101 108 102 static void ocelot_mm_update_port_status(struct ocelot *ocelot, int port)
-6
drivers/net/ethernet/pensando/ionic/ionic_bus_pci.c
··· 353 353 ionic_reset(ionic); 354 354 err_out_teardown: 355 355 ionic_dev_teardown(ionic); 356 - pci_clear_master(pdev); 357 - /* Don't fail the probe for these errors, keep 358 - * the hw interface around for inspection 359 - */ 360 - return 0; 361 - 362 356 err_out_unmap_bars: 363 357 ionic_unmap_bars(ionic); 364 358 err_out_pci_release_regions:
-5
drivers/net/ethernet/pensando/ionic/ionic_lif.c
··· 475 475 static void ionic_link_qcq_interrupts(struct ionic_qcq *src_qcq, 476 476 struct ionic_qcq *n_qcq) 477 477 { 478 - if (WARN_ON(n_qcq->flags & IONIC_QCQ_F_INTR)) { 479 - ionic_intr_free(n_qcq->cq.lif->ionic, n_qcq->intr.index); 480 - n_qcq->flags &= ~IONIC_QCQ_F_INTR; 481 - } 482 - 483 478 n_qcq->intr.vector = src_qcq->intr.vector; 484 479 n_qcq->intr.index = src_qcq->intr.index; 485 480 n_qcq->napi_qcq = src_qcq->napi_qcq;
-3
drivers/net/ethernet/wangxun/txgbe/txgbe_hw.c
··· 186 186 if (eeprom_ptrs) 187 187 kvfree(eeprom_ptrs); 188 188 189 - if (*checksum > TXGBE_EEPROM_SUM) 190 - return -EINVAL; 191 - 192 189 *checksum = TXGBE_EEPROM_SUM - *checksum; 193 190 194 191 return 0;
+3 -6
drivers/net/netdevsim/dev.c
··· 184 184 cookie_len = (count - 1) / 2; 185 185 if ((count - 1) % 2) 186 186 return -EINVAL; 187 - buf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN); 188 - if (!buf) 189 - return -ENOMEM; 190 187 191 - ret = simple_write_to_buffer(buf, count, ppos, data, count); 192 - if (ret < 0) 193 - goto free_buf; 188 + buf = memdup_user(data, count); 189 + if (IS_ERR(buf)) 190 + return PTR_ERR(buf); 194 191 195 192 fa_cookie = kmalloc(sizeof(*fa_cookie) + cookie_len, 196 193 GFP_KERNEL | __GFP_NOWARN);
+4 -1
drivers/net/wireless/cisco/airo.c
··· 6157 6157 struct iw_param *vwrq = &wrqu->bitrate; 6158 6158 struct airo_info *local = dev->ml_priv; 6159 6159 StatusRid status_rid; /* Card status info */ 6160 + int ret; 6160 6161 6161 - readStatusRid(local, &status_rid, 1); 6162 + ret = readStatusRid(local, &status_rid, 1); 6163 + if (ret) 6164 + return -EBUSY; 6162 6165 6163 6166 vwrq->value = le16_to_cpu(status_rid.currentXmitRate) * 500000; 6164 6167 /* If more than one rate, set auto */
-5
drivers/net/wireless/intel/iwlwifi/cfg/22000.c
··· 84 84 .mac_addr_from_csr = 0x380, \ 85 85 .ht_params = &iwl_22000_ht_params, \ 86 86 .nvm_ver = IWL_22000_NVM_VERSION, \ 87 - .trans.use_tfh = true, \ 88 87 .trans.rf_id = true, \ 89 88 .trans.gen2 = true, \ 90 89 .nvm_type = IWL_NVM_EXT, \ ··· 121 122 122 123 const struct iwl_cfg_trans_params iwl_qu_trans_cfg = { 123 124 .mq_rx_supported = true, 124 - .use_tfh = true, 125 125 .rf_id = true, 126 126 .gen2 = true, 127 127 .device_family = IWL_DEVICE_FAMILY_22000, ··· 132 134 133 135 const struct iwl_cfg_trans_params iwl_qu_medium_latency_trans_cfg = { 134 136 .mq_rx_supported = true, 135 - .use_tfh = true, 136 137 .rf_id = true, 137 138 .gen2 = true, 138 139 .device_family = IWL_DEVICE_FAMILY_22000, ··· 143 146 144 147 const struct iwl_cfg_trans_params iwl_qu_long_latency_trans_cfg = { 145 148 .mq_rx_supported = true, 146 - .use_tfh = true, 147 149 .rf_id = true, 148 150 .gen2 = true, 149 151 .device_family = IWL_DEVICE_FAMILY_22000, ··· 196 200 .device_family = IWL_DEVICE_FAMILY_22000, 197 201 .base_params = &iwl_22000_base_params, 198 202 .mq_rx_supported = true, 199 - .use_tfh = true, 200 203 .rf_id = true, 201 204 .gen2 = true, 202 205 .bisr_workaround = 1,
-2
drivers/net/wireless/intel/iwlwifi/iwl-config.h
··· 256 256 * @xtal_latency: power up latency to get the xtal stabilized 257 257 * @extra_phy_cfg_flags: extra configuration flags to pass to the PHY 258 258 * @rf_id: need to read rf_id to determine the firmware image 259 - * @use_tfh: use TFH 260 259 * @gen2: 22000 and on transport operation 261 260 * @mq_rx_supported: multi-queue rx support 262 261 * @integrated: discrete or integrated ··· 270 271 u32 xtal_latency; 271 272 u32 extra_phy_cfg_flags; 272 273 u32 rf_id:1, 273 - use_tfh:1, 274 274 gen2:1, 275 275 mq_rx_supported:1, 276 276 integrated:1,
+2 -2
drivers/net/wireless/intel/iwlwifi/iwl-fh.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2005-2014, 2018-2021 Intel Corporation 3 + * Copyright (C) 2005-2014, 2018-2021, 2023 Intel Corporation 4 4 * Copyright (C) 2015-2017 Intel Deutschland GmbH 5 5 */ 6 6 #ifndef __iwl_fh_h__ ··· 71 71 static inline unsigned int FH_MEM_CBBC_QUEUE(struct iwl_trans *trans, 72 72 unsigned int chnl) 73 73 { 74 - if (trans->trans_cfg->use_tfh) { 74 + if (trans->trans_cfg->gen2) { 75 75 WARN_ON_ONCE(chnl >= 64); 76 76 return TFH_TFDQ_CBB_TABLE + 8 * chnl; 77 77 }
+3 -3
drivers/net/wireless/intel/iwlwifi/iwl-trans.c
··· 2 2 /* 3 3 * Copyright (C) 2015 Intel Mobile Communications GmbH 4 4 * Copyright (C) 2016-2017 Intel Deutschland GmbH 5 - * Copyright (C) 2019-2021 Intel Corporation 5 + * Copyright (C) 2019-2021, 2023 Intel Corporation 6 6 */ 7 7 #include <linux/kernel.h> 8 8 #include <linux/bsearch.h> ··· 42 42 43 43 WARN_ON(!ops->wait_txq_empty && !ops->wait_tx_queues_empty); 44 44 45 - if (trans->trans_cfg->use_tfh) { 45 + if (trans->trans_cfg->gen2) { 46 46 trans->txqs.tfd.addr_size = 64; 47 47 trans->txqs.tfd.max_tbs = IWL_TFH_NUM_TBS; 48 48 trans->txqs.tfd.size = sizeof(struct iwl_tfh_tfd); ··· 101 101 102 102 /* Some things must not change even if the config does */ 103 103 WARN_ON(trans->txqs.tfd.addr_size != 104 - (trans->trans_cfg->use_tfh ? 64 : 36)); 104 + (trans->trans_cfg->gen2 ? 64 : 36)); 105 105 106 106 snprintf(trans->dev_cmd_pool_name, sizeof(trans->dev_cmd_pool_name), 107 107 "iwl_cmd_pool:%s", dev_name(trans->dev));
+1 -1
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h
··· 1450 1450 static inline bool iwl_mvm_has_new_tx_api(struct iwl_mvm *mvm) 1451 1451 { 1452 1452 /* TODO - replace with TLV once defined */ 1453 - return mvm->trans->trans_cfg->use_tfh; 1453 + return mvm->trans->trans_cfg->gen2; 1454 1454 } 1455 1455 1456 1456 static inline bool iwl_mvm_has_unified_ucode(struct iwl_mvm *mvm)
+2 -2
drivers/net/wireless/intel/iwlwifi/pcie/trans.c
··· 819 819 820 820 iwl_enable_interrupts(trans); 821 821 822 - if (trans->trans_cfg->use_tfh) { 822 + if (trans->trans_cfg->gen2) { 823 823 if (cpu == 1) 824 824 iwl_write_prph(trans, UREG_UCODE_LOAD_STATUS, 825 825 0xFFFF); ··· 3394 3394 u8 tfdidx; 3395 3395 u32 caplen, cmdlen; 3396 3396 3397 - if (trans->trans_cfg->use_tfh) 3397 + if (trans->trans_cfg->gen2) 3398 3398 tfdidx = idx; 3399 3399 else 3400 3400 tfdidx = ptr;
+1 -1
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
··· 364 364 for (txq_id = 0; txq_id < trans->trans_cfg->base_params->num_of_queues; 365 365 txq_id++) { 366 366 struct iwl_txq *txq = trans->txqs.txq[txq_id]; 367 - if (trans->trans_cfg->use_tfh) 367 + if (trans->trans_cfg->gen2) 368 368 iwl_write_direct64(trans, 369 369 FH_MEM_CBBC_QUEUE(trans, txq_id), 370 370 txq->dma_addr);
+5 -5
drivers/net/wireless/intel/iwlwifi/queue/tx.c
··· 985 985 bool active; 986 986 u8 fifo; 987 987 988 - if (trans->trans_cfg->use_tfh) { 988 + if (trans->trans_cfg->gen2) { 989 989 IWL_ERR(trans, "Queue %d is stuck %d %d\n", txq_id, 990 990 txq->read_ptr, txq->write_ptr); 991 991 /* TODO: access new SCD registers and dump them */ ··· 1040 1040 if (WARN_ON(txq->entries || txq->tfds)) 1041 1041 return -EINVAL; 1042 1042 1043 - if (trans->trans_cfg->use_tfh) 1043 + if (trans->trans_cfg->gen2) 1044 1044 tfd_sz = trans->txqs.tfd.size * slots_num; 1045 1045 1046 1046 timer_setup(&txq->stuck_timer, iwl_txq_stuck_timer, 0); ··· 1347 1347 dma_addr_t addr; 1348 1348 dma_addr_t hi_len; 1349 1349 1350 - if (trans->trans_cfg->use_tfh) { 1350 + if (trans->trans_cfg->gen2) { 1351 1351 struct iwl_tfh_tfd *tfh_tfd = _tfd; 1352 1352 struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx]; 1353 1353 ··· 1408 1408 1409 1409 meta->tbs = 0; 1410 1410 1411 - if (trans->trans_cfg->use_tfh) { 1411 + if (trans->trans_cfg->gen2) { 1412 1412 struct iwl_tfh_tfd *tfd_fh = (void *)tfd; 1413 1413 1414 1414 tfd_fh->num_tbs = 0; ··· 1625 1625 1626 1626 txq->entries[read_ptr].skb = NULL; 1627 1627 1628 - if (!trans->trans_cfg->use_tfh) 1628 + if (!trans->trans_cfg->gen2) 1629 1629 iwl_txq_gen1_inval_byte_cnt_tbl(trans, txq); 1630 1630 1631 1631 iwl_txq_free_tfd(trans, txq);
+4 -4
drivers/net/wireless/intel/iwlwifi/queue/tx.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2 2 /* 3 - * Copyright (C) 2020-2022 Intel Corporation 3 + * Copyright (C) 2020-2023 Intel Corporation 4 4 */ 5 5 #ifndef __iwl_trans_queue_tx_h__ 6 6 #define __iwl_trans_queue_tx_h__ ··· 38 38 static inline void *iwl_txq_get_tfd(struct iwl_trans *trans, 39 39 struct iwl_txq *txq, int idx) 40 40 { 41 - if (trans->trans_cfg->use_tfh) 41 + if (trans->trans_cfg->gen2) 42 42 idx = iwl_txq_get_cmd_index(txq, idx); 43 43 44 44 return (u8 *)txq->tfds + trans->txqs.tfd.size * idx; ··· 135 135 { 136 136 struct iwl_tfd *tfd; 137 137 138 - if (trans->trans_cfg->use_tfh) { 138 + if (trans->trans_cfg->gen2) { 139 139 struct iwl_tfh_tfd *tfh_tfd = _tfd; 140 140 141 141 return le16_to_cpu(tfh_tfd->num_tbs) & 0x1f; ··· 151 151 struct iwl_tfd *tfd; 152 152 struct iwl_tfd_tb *tb; 153 153 154 - if (trans->trans_cfg->use_tfh) { 154 + if (trans->trans_cfg->gen2) { 155 155 struct iwl_tfh_tfd *tfh_tfd = _tfd; 156 156 struct iwl_tfh_tb *tfh_tb = &tfh_tfd->tbs[idx]; 157 157
-4
drivers/net/wireless/mediatek/mt76/mt7921/dma.c
··· 231 231 if (ret) 232 232 return ret; 233 233 234 - ret = mt7921_wfsys_reset(dev); 235 - if (ret) 236 - return ret; 237 - 238 234 /* init tx queue */ 239 235 ret = mt76_connac_init_tx_queues(dev->phy.mt76, MT7921_TXQ_BAND0, 240 236 MT7921_TX_RING_SIZE,
-8
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c
··· 476 476 { 477 477 int ret; 478 478 479 - ret = mt76_get_field(dev, MT_CONN_ON_MISC, MT_TOP_MISC2_FW_N9_RDY); 480 - if (ret && mt76_is_mmio(&dev->mt76)) { 481 - dev_dbg(dev->mt76.dev, "Firmware is already download\n"); 482 - goto fw_loaded; 483 - } 484 - 485 479 ret = mt76_connac2_load_patch(&dev->mt76, mt7921_patch_name(dev)); 486 480 if (ret) 487 481 return ret; ··· 497 503 498 504 return -EIO; 499 505 } 500 - 501 - fw_loaded: 502 506 503 507 #ifdef CONFIG_PM 504 508 dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;
+8
drivers/net/wireless/mediatek/mt76/mt7921/pci.c
··· 325 325 bus_ops->rmw = mt7921_rmw; 326 326 dev->mt76.bus = bus_ops; 327 327 328 + ret = mt7921e_mcu_fw_pmctrl(dev); 329 + if (ret) 330 + goto err_free_dev; 331 + 328 332 ret = __mt7921e_mcu_drv_pmctrl(dev); 329 333 if (ret) 330 334 goto err_free_dev; ··· 336 332 mdev->rev = (mt7921_l1_rr(dev, MT_HW_CHIPID) << 16) | 337 333 (mt7921_l1_rr(dev, MT_HW_REV) & 0xff); 338 334 dev_info(mdev->dev, "ASIC revision: %04x\n", mdev->rev); 335 + 336 + ret = mt7921_wfsys_reset(dev); 337 + if (ret) 338 + goto err_free_dev; 339 339 340 340 mt76_wr(dev, MT_WFDMA0_HOST_INT_ENA, 0); 341 341
+3 -2
drivers/net/wireless/realtek/rtw89/debug.c
··· 3026 3026 struct rtw89_debugfs_priv *debugfs_priv = filp->private_data; 3027 3027 struct rtw89_dev *rtwdev = debugfs_priv->rtwdev; 3028 3028 u8 *h2c; 3029 + int ret; 3029 3030 u16 h2c_len = count / 2; 3030 3031 3031 3032 h2c = rtw89_hex2bin_user(rtwdev, user_buf, count); 3032 3033 if (IS_ERR(h2c)) 3033 3034 return -EFAULT; 3034 3035 3035 - rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len); 3036 + ret = rtw89_fw_h2c_raw(rtwdev, h2c, h2c_len); 3036 3037 3037 3038 kfree(h2c); 3038 3039 3039 - return count; 3040 + return ret ? ret : count; 3040 3041 } 3041 3042 3042 3043 static int
+73 -80
drivers/s390/net/ism_drv.c
··· 36 36 static struct ism_client *clients[MAX_CLIENTS]; /* use an array rather than */ 37 37 /* a list for fast mapping */ 38 38 static u8 max_client; 39 - static DEFINE_SPINLOCK(clients_lock); 39 + static DEFINE_MUTEX(clients_lock); 40 40 struct ism_dev_list { 41 41 struct list_head list; 42 42 struct mutex mutex; /* protects ism device list */ ··· 47 47 .mutex = __MUTEX_INITIALIZER(ism_dev_list.mutex), 48 48 }; 49 49 50 + static void ism_setup_forwarding(struct ism_client *client, struct ism_dev *ism) 51 + { 52 + unsigned long flags; 53 + 54 + spin_lock_irqsave(&ism->lock, flags); 55 + ism->subs[client->id] = client; 56 + spin_unlock_irqrestore(&ism->lock, flags); 57 + } 58 + 50 59 int ism_register_client(struct ism_client *client) 51 60 { 52 61 struct ism_dev *ism; 53 - unsigned long flags; 54 62 int i, rc = -ENOSPC; 55 63 56 64 mutex_lock(&ism_dev_list.mutex); 57 - spin_lock_irqsave(&clients_lock, flags); 65 + mutex_lock(&clients_lock); 58 66 for (i = 0; i < MAX_CLIENTS; ++i) { 59 67 if (!clients[i]) { 60 68 clients[i] = client; ··· 73 65 break; 74 66 } 75 67 } 76 - spin_unlock_irqrestore(&clients_lock, flags); 68 + mutex_unlock(&clients_lock); 69 + 77 70 if (i < MAX_CLIENTS) { 78 71 /* initialize with all devices that we got so far */ 79 72 list_for_each_entry(ism, &ism_dev_list.list, list) { 80 73 ism->priv[i] = NULL; 81 74 client->add(ism); 75 + ism_setup_forwarding(client, ism); 82 76 } 83 77 } 84 78 mutex_unlock(&ism_dev_list.mutex); ··· 96 86 int rc = 0; 97 87 98 88 mutex_lock(&ism_dev_list.mutex); 99 - spin_lock_irqsave(&clients_lock, flags); 89 + list_for_each_entry(ism, &ism_dev_list.list, list) { 90 + spin_lock_irqsave(&ism->lock, flags); 91 + /* Stop forwarding IRQs and events */ 92 + ism->subs[client->id] = NULL; 93 + for (int i = 0; i < ISM_NR_DMBS; ++i) { 94 + if (ism->sba_client_arr[i] == client->id) { 95 + WARN(1, "%s: attempt to unregister '%s' with registered dmb(s)\n", 96 + __func__, client->name); 97 + rc = -EBUSY; 98 + goto err_reg_dmb; 99 + } 100 + } 101 + spin_unlock_irqrestore(&ism->lock, flags); 102 + } 103 + mutex_unlock(&ism_dev_list.mutex); 104 + 105 + mutex_lock(&clients_lock); 100 106 clients[client->id] = NULL; 101 107 if (client->id + 1 == max_client) 102 108 max_client--; 103 - spin_unlock_irqrestore(&clients_lock, flags); 104 - list_for_each_entry(ism, &ism_dev_list.list, list) { 105 - for (int i = 0; i < ISM_NR_DMBS; ++i) { 106 - if (ism->sba_client_arr[i] == client->id) { 107 - pr_err("%s: attempt to unregister client '%s'" 108 - "with registered dmb(s)\n", __func__, 109 - client->name); 110 - rc = -EBUSY; 111 - goto out; 112 - } 113 - } 114 - } 115 - out: 116 - mutex_unlock(&ism_dev_list.mutex); 109 + mutex_unlock(&clients_lock); 110 + return rc; 117 111 112 + err_reg_dmb: 113 + spin_unlock_irqrestore(&ism->lock, flags); 114 + mutex_unlock(&ism_dev_list.mutex); 118 115 return rc; 119 116 } 120 117 EXPORT_SYMBOL_GPL(ism_unregister_client); ··· 345 328 struct ism_client *client) 346 329 { 347 330 union ism_reg_dmb cmd; 331 + unsigned long flags; 348 332 int ret; 349 333 350 334 ret = ism_alloc_dmb(ism, dmb); ··· 369 351 goto out; 370 352 } 371 353 dmb->dmb_tok = cmd.response.dmb_tok; 354 + spin_lock_irqsave(&ism->lock, flags); 372 355 ism->sba_client_arr[dmb->sba_idx - ISM_DMB_BIT_OFFSET] = client->id; 356 + spin_unlock_irqrestore(&ism->lock, flags); 373 357 out: 374 358 return ret; 375 359 } ··· 380 360 int ism_unregister_dmb(struct ism_dev *ism, struct ism_dmb *dmb) 381 361 { 382 362 union ism_unreg_dmb cmd; 363 + unsigned long flags; 383 364 int ret; 384 365 385 366 memset(&cmd, 0, sizeof(cmd)); ··· 389 368 390 369 cmd.request.dmb_tok = dmb->dmb_tok; 391 370 371 + spin_lock_irqsave(&ism->lock, flags); 392 372 ism->sba_client_arr[dmb->sba_idx - ISM_DMB_BIT_OFFSET] = NO_CLIENT; 373 + spin_unlock_irqrestore(&ism->lock, flags); 393 374 394 375 ret = ism_cmd(ism, &cmd); 395 376 if (ret && ret != ISM_ERROR) ··· 514 491 static void ism_handle_event(struct ism_dev *ism) 515 492 { 516 493 struct ism_event *entry; 494 + struct ism_client *clt; 517 495 int i; 518 496 519 497 while ((ism->ieq_idx + 1) != READ_ONCE(ism->ieq->header.idx)) { ··· 523 499 524 500 entry = &ism->ieq->entry[ism->ieq_idx]; 525 501 debug_event(ism_debug_info, 2, entry, sizeof(*entry)); 526 - spin_lock(&clients_lock); 527 - for (i = 0; i < max_client; ++i) 528 - if (clients[i]) 529 - clients[i]->handle_event(ism, entry); 530 - spin_unlock(&clients_lock); 502 + for (i = 0; i < max_client; ++i) { 503 + clt = ism->subs[i]; 504 + if (clt) 505 + clt->handle_event(ism, entry); 506 + } 531 507 } 532 508 } 533 509 534 510 static irqreturn_t ism_handle_irq(int irq, void *data) 535 511 { 536 512 struct ism_dev *ism = data; 537 - struct ism_client *clt; 538 513 unsigned long bit, end; 539 514 unsigned long *bv; 540 515 u16 dmbemask; 516 + u8 client_id; 541 517 542 518 bv = (void *) &ism->sba->dmb_bits[ISM_DMB_WORD_OFFSET]; 543 519 end = sizeof(ism->sba->dmb_bits) * BITS_PER_BYTE - ISM_DMB_BIT_OFFSET; ··· 554 530 dmbemask = ism->sba->dmbe_mask[bit + ISM_DMB_BIT_OFFSET]; 555 531 ism->sba->dmbe_mask[bit + ISM_DMB_BIT_OFFSET] = 0; 556 532 barrier(); 557 - clt = clients[ism->sba_client_arr[bit]]; 558 - clt->handle_irq(ism, bit + ISM_DMB_BIT_OFFSET, dmbemask); 533 + client_id = ism->sba_client_arr[bit]; 534 + if (unlikely(client_id == NO_CLIENT || !ism->subs[client_id])) 535 + continue; 536 + ism->subs[client_id]->handle_irq(ism, bit + ISM_DMB_BIT_OFFSET, dmbemask); 559 537 } 560 538 561 539 if (ism->sba->e) { ··· 574 548 return ism->local_gid; 575 549 } 576 550 577 - static void ism_dev_add_work_func(struct work_struct *work) 578 - { 579 - struct ism_client *client = container_of(work, struct ism_client, 580 - add_work); 581 - 582 - client->add(client->tgt_ism); 583 - atomic_dec(&client->tgt_ism->add_dev_cnt); 584 - wake_up(&client->tgt_ism->waitq); 585 - } 586 - 587 551 static int ism_dev_init(struct ism_dev *ism) 588 552 { 589 553 struct pci_dev *pdev = ism->pdev; 590 - unsigned long flags; 591 554 int i, ret; 592 555 593 556 ret = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI); ··· 609 594 /* hardware is V2 capable */ 610 595 ism_create_system_eid(); 611 596 612 - init_waitqueue_head(&ism->waitq); 613 - atomic_set(&ism->free_clients_cnt, 0); 614 - atomic_set(&ism->add_dev_cnt, 0); 615 - 616 - wait_event(ism->waitq, !atomic_read(&ism->add_dev_cnt)); 617 - spin_lock_irqsave(&clients_lock, flags); 618 - for (i = 0; i < max_client; ++i) 619 - if (clients[i]) { 620 - INIT_WORK(&clients[i]->add_work, 621 - ism_dev_add_work_func); 622 - clients[i]->tgt_ism = ism; 623 - atomic_inc(&ism->add_dev_cnt); 624 - schedule_work(&clients[i]->add_work); 625 - } 626 - spin_unlock_irqrestore(&clients_lock, flags); 627 - 628 - wait_event(ism->waitq, !atomic_read(&ism->add_dev_cnt)); 629 - 630 597 mutex_lock(&ism_dev_list.mutex); 598 + mutex_lock(&clients_lock); 599 + for (i = 0; i < max_client; ++i) { 600 + if (clients[i]) { 601 + clients[i]->add(ism); 602 + ism_setup_forwarding(clients[i], ism); 603 + } 604 + } 605 + mutex_unlock(&clients_lock); 606 + 631 607 list_add(&ism->list, &ism_dev_list.list); 632 608 mutex_unlock(&ism_dev_list.mutex); 633 609 ··· 693 687 return ret; 694 688 } 695 689 696 - static void ism_dev_remove_work_func(struct work_struct *work) 697 - { 698 - struct ism_client *client = container_of(work, struct ism_client, 699 - remove_work); 700 - 701 - client->remove(client->tgt_ism); 702 - atomic_dec(&client->tgt_ism->free_clients_cnt); 703 - wake_up(&client->tgt_ism->waitq); 704 - } 705 - 706 - /* Callers must hold ism_dev_list.mutex */ 707 690 static void ism_dev_exit(struct ism_dev *ism) 708 691 { 709 692 struct pci_dev *pdev = ism->pdev; 710 693 unsigned long flags; 711 694 int i; 712 695 713 - wait_event(ism->waitq, !atomic_read(&ism->free_clients_cnt)); 714 - spin_lock_irqsave(&clients_lock, flags); 696 + spin_lock_irqsave(&ism->lock, flags); 715 697 for (i = 0; i < max_client; ++i) 716 - if (clients[i]) { 717 - INIT_WORK(&clients[i]->remove_work, 718 - ism_dev_remove_work_func); 719 - clients[i]->tgt_ism = ism; 720 - atomic_inc(&ism->free_clients_cnt); 721 - schedule_work(&clients[i]->remove_work); 722 - } 723 - spin_unlock_irqrestore(&clients_lock, flags); 698 + ism->subs[i] = NULL; 699 + spin_unlock_irqrestore(&ism->lock, flags); 724 700 725 - wait_event(ism->waitq, !atomic_read(&ism->free_clients_cnt)); 701 + mutex_lock(&ism_dev_list.mutex); 702 + mutex_lock(&clients_lock); 703 + for (i = 0; i < max_client; ++i) { 704 + if (clients[i]) 705 + clients[i]->remove(ism); 706 + } 707 + mutex_unlock(&clients_lock); 726 708 727 709 if (SYSTEM_EID.serial_number[0] != '0' || 728 710 SYSTEM_EID.type[0] != '0') ··· 721 727 kfree(ism->sba_client_arr); 722 728 pci_free_irq_vectors(pdev); 723 729 list_del_init(&ism->list); 730 + mutex_unlock(&ism_dev_list.mutex); 724 731 } 725 732 726 733 static void ism_remove(struct pci_dev *pdev) 727 734 { 728 735 struct ism_dev *ism = dev_get_drvdata(&pdev->dev); 729 736 730 - mutex_lock(&ism_dev_list.mutex); 731 737 ism_dev_exit(ism); 732 - mutex_unlock(&ism_dev_list.mutex); 733 738 734 739 pci_release_mem_regions(pdev); 735 740 pci_disable_device(pdev);
+1 -6
include/linux/ism.h
··· 44 44 u64 local_gid; 45 45 int ieq_idx; 46 46 47 - atomic_t free_clients_cnt; 48 - atomic_t add_dev_cnt; 49 - wait_queue_head_t waitq; 47 + struct ism_client *subs[MAX_CLIENTS]; 50 48 }; 51 49 52 50 struct ism_event { ··· 66 68 */ 67 69 void (*handle_irq)(struct ism_dev *dev, unsigned int bit, u16 dmbemask); 68 70 /* Private area - don't touch! */ 69 - struct work_struct remove_work; 70 - struct work_struct add_work; 71 - struct ism_dev *tgt_ism; 72 71 u8 id; 73 72 }; 74 73
+3
include/net/netfilter/nf_conntrack_tuple.h
··· 67 67 /* The protocol. */ 68 68 u_int8_t protonum; 69 69 70 + /* The direction must be ignored for the tuplehash */ 71 + struct { } __nfct_hash_offsetend; 72 + 70 73 /* The direction (for tuplehash) */ 71 74 u_int8_t dir; 72 75 } dst;
+27 -4
include/net/netfilter/nf_tables.h
··· 1211 1211 1212 1212 unsigned int nft_do_chain(struct nft_pktinfo *pkt, void *priv); 1213 1213 1214 + static inline bool nft_use_inc(u32 *use) 1215 + { 1216 + if (*use == UINT_MAX) 1217 + return false; 1218 + 1219 + (*use)++; 1220 + 1221 + return true; 1222 + } 1223 + 1224 + static inline void nft_use_dec(u32 *use) 1225 + { 1226 + WARN_ON_ONCE((*use)-- == 0); 1227 + } 1228 + 1229 + /* For error and abort path: restore use counter to previous state. */ 1230 + static inline void nft_use_inc_restore(u32 *use) 1231 + { 1232 + WARN_ON_ONCE(!nft_use_inc(use)); 1233 + } 1234 + 1235 + #define nft_use_dec_restore nft_use_dec 1236 + 1214 1237 /** 1215 1238 * struct nft_table - nf_tables table 1216 1239 * ··· 1319 1296 struct list_head list; 1320 1297 struct rhlist_head rhlhead; 1321 1298 struct nft_object_hash_key key; 1322 - u32 genmask:2, 1323 - use:30; 1299 + u32 genmask:2; 1300 + u32 use; 1324 1301 u64 handle; 1325 1302 u16 udlen; 1326 1303 u8 *udata; ··· 1422 1399 char *name; 1423 1400 int hooknum; 1424 1401 int ops_len; 1425 - u32 genmask:2, 1426 - use:30; 1402 + u32 genmask:2; 1403 + u32 use; 1427 1404 u64 handle; 1428 1405 /* runtime data below here */ 1429 1406 struct list_head hook_list ____cacheline_aligned;
+1 -1
include/net/pkt_sched.h
··· 134 134 */ 135 135 static inline unsigned int psched_mtu(const struct net_device *dev) 136 136 { 137 - return dev->mtu + dev->hard_header_len; 137 + return READ_ONCE(dev->mtu) + dev->hard_header_len; 138 138 } 139 139 140 140 static inline struct net *qdisc_net(struct Qdisc *q)
+5 -4
include/soc/mscc/ocelot.h
··· 663 663 struct flow_stats *stats); 664 664 void (*cut_through_fwd)(struct ocelot *ocelot); 665 665 void (*tas_clock_adjust)(struct ocelot *ocelot); 666 + void (*tas_guard_bands_update)(struct ocelot *ocelot, int port); 666 667 void (*update_stats)(struct ocelot *ocelot); 667 668 }; 668 669 ··· 864 863 struct mutex stat_view_lock; 865 864 /* Lock for serializing access to the MAC table */ 866 865 struct mutex mact_lock; 867 - /* Lock for serializing forwarding domain changes */ 866 + /* Lock for serializing forwarding domain changes, including the 867 + * configuration of the Time-Aware Shaper, MAC Merge layer and 868 + * cut-through forwarding, on which it depends 869 + */ 868 870 struct mutex fwd_domain_lock; 869 - 870 - /* Lock for serializing Time-Aware Shaper changes */ 871 - struct mutex tas_lock; 872 871 873 872 struct workqueue_struct *owq; 874 873
+24 -16
kernel/bpf/cpumap.c
··· 122 122 atomic_inc(&rcpu->refcnt); 123 123 } 124 124 125 - /* called from workqueue, to workaround syscall using preempt_disable */ 126 - static void cpu_map_kthread_stop(struct work_struct *work) 127 - { 128 - struct bpf_cpu_map_entry *rcpu; 129 - 130 - rcpu = container_of(work, struct bpf_cpu_map_entry, kthread_stop_wq); 131 - 132 - /* Wait for flush in __cpu_map_entry_free(), via full RCU barrier, 133 - * as it waits until all in-flight call_rcu() callbacks complete. 134 - */ 135 - rcu_barrier(); 136 - 137 - /* kthread_stop will wake_up_process and wait for it to complete */ 138 - kthread_stop(rcpu->kthread); 139 - } 140 - 141 125 static void __cpu_map_ring_cleanup(struct ptr_ring *ring) 142 126 { 143 127 /* The tear-down procedure should have made sure that queue is ··· 146 162 ptr_ring_cleanup(rcpu->queue, NULL); 147 163 kfree(rcpu->queue); 148 164 kfree(rcpu); 165 + } 166 + } 167 + 168 + /* called from workqueue, to workaround syscall using preempt_disable */ 169 + static void cpu_map_kthread_stop(struct work_struct *work) 170 + { 171 + struct bpf_cpu_map_entry *rcpu; 172 + int err; 173 + 174 + rcpu = container_of(work, struct bpf_cpu_map_entry, kthread_stop_wq); 175 + 176 + /* Wait for flush in __cpu_map_entry_free(), via full RCU barrier, 177 + * as it waits until all in-flight call_rcu() callbacks complete. 178 + */ 179 + rcu_barrier(); 180 + 181 + /* kthread_stop will wake_up_process and wait for it to complete */ 182 + err = kthread_stop(rcpu->kthread); 183 + if (err) { 184 + /* kthread_stop may be called before cpu_map_kthread_run 185 + * is executed, so we need to release the memory related 186 + * to rcpu. 187 + */ 188 + put_cpu_map_entry(rcpu); 149 189 } 150 190 } 151 191
+3 -2
kernel/bpf/verifier.c
··· 5642 5642 verbose(env, "verifier bug. subprog has tail_call and async cb\n"); 5643 5643 return -EFAULT; 5644 5644 } 5645 - /* async callbacks don't increase bpf prog stack size */ 5646 - continue; 5645 + /* async callbacks don't increase bpf prog stack size unless called directly */ 5646 + if (!bpf_pseudo_call(insn + i)) 5647 + continue; 5647 5648 } 5648 5649 i = next_insn; 5649 5650
+2
net/core/net-traces.c
··· 63 63 EXPORT_TRACEPOINT_SYMBOL_GPL(tcp_send_reset); 64 64 EXPORT_TRACEPOINT_SYMBOL_GPL(tcp_bad_csum); 65 65 66 + EXPORT_TRACEPOINT_SYMBOL_GPL(udp_fail_queue_rcv_skb); 67 + 66 68 EXPORT_TRACEPOINT_SYMBOL_GPL(sk_data_ready);
+5
net/core/skbuff.c
··· 4261 4261 4262 4262 skb_push(skb, -skb_network_offset(skb) + offset); 4263 4263 4264 + /* Ensure the head is writeable before touching the shared info */ 4265 + err = skb_unclone(skb, GFP_ATOMIC); 4266 + if (err) 4267 + goto err_linearize; 4268 + 4264 4269 skb_shinfo(skb)->frag_list = NULL; 4265 4270 4266 4271 while (list_skb) {
+1 -1
net/core/xdp.c
··· 741 741 __diag_pop(); 742 742 743 743 BTF_SET8_START(xdp_metadata_kfunc_ids) 744 - #define XDP_METADATA_KFUNC(_, name) BTF_ID_FLAGS(func, name, 0) 744 + #define XDP_METADATA_KFUNC(_, name) BTF_ID_FLAGS(func, name, KF_TRUSTED_ARGS) 745 745 XDP_METADATA_KFUNC_xxx 746 746 #undef XDP_METADATA_KFUNC 747 747 BTF_SET8_END(xdp_metadata_kfunc_ids)
+1 -2
net/ipv6/addrconf.c
··· 318 318 static void addrconf_mod_rs_timer(struct inet6_dev *idev, 319 319 unsigned long when) 320 320 { 321 - if (!timer_pending(&idev->rs_timer)) 321 + if (!mod_timer(&idev->rs_timer, jiffies + when)) 322 322 in6_dev_hold(idev); 323 - mod_timer(&idev->rs_timer, jiffies + when); 324 323 } 325 324 326 325 static void addrconf_mod_dad_work(struct inet6_ifaddr *ifp,
+4 -1
net/ipv6/icmp.c
··· 424 424 if (unlikely(dev->ifindex == LOOPBACK_IFINDEX || netif_is_l3_master(skb->dev))) { 425 425 const struct rt6_info *rt6 = skb_rt6_info(skb); 426 426 427 - if (rt6) 427 + /* The destination could be an external IP in Ext Hdr (SRv6, RPL, etc.), 428 + * and ip6_null_entry could be set to skb if no route is found. 429 + */ 430 + if (rt6 && rt6->rt6i_idev) 428 431 dev = rt6->rt6i_idev->dev; 429 432 } 430 433
+3 -1
net/ipv6/udp.c
··· 45 45 #include <net/tcp_states.h> 46 46 #include <net/ip6_checksum.h> 47 47 #include <net/ip6_tunnel.h> 48 + #include <trace/events/udp.h> 48 49 #include <net/xfrm.h> 49 50 #include <net/inet_hashtables.h> 50 51 #include <net/inet6_hashtables.h> ··· 91 90 fhash = __ipv6_addr_jhash(faddr, udp_ipv6_hash_secret); 92 91 93 92 return __inet6_ehashfn(lhash, lport, fhash, fport, 94 - udp_ipv6_hash_secret + net_hash_mix(net)); 93 + udp6_ehash_secret + net_hash_mix(net)); 95 94 } 96 95 97 96 int udp_v6_get_port(struct sock *sk, unsigned short snum) ··· 681 680 } 682 681 UDP6_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, is_udplite); 683 682 kfree_skb_reason(skb, drop_reason); 683 + trace_udp_fail_queue_rcv_skb(rc, sk); 684 684 return -1; 685 685 } 686 686
+7 -13
net/netfilter/nf_conntrack_core.c
··· 211 211 unsigned int zoneid, 212 212 const struct net *net) 213 213 { 214 - u64 a, b, c, d; 214 + siphash_key_t key; 215 215 216 216 get_random_once(&nf_conntrack_hash_rnd, sizeof(nf_conntrack_hash_rnd)); 217 217 218 - /* The direction must be ignored, handle usable tuplehash members manually */ 219 - a = (u64)tuple->src.u3.all[0] << 32 | tuple->src.u3.all[3]; 220 - b = (u64)tuple->dst.u3.all[0] << 32 | tuple->dst.u3.all[3]; 218 + key = nf_conntrack_hash_rnd; 221 219 222 - c = (__force u64)tuple->src.u.all << 32 | (__force u64)tuple->dst.u.all << 16; 223 - c |= tuple->dst.protonum; 220 + key.key[0] ^= zoneid; 221 + key.key[1] ^= net_hash_mix(net); 224 222 225 - d = (u64)zoneid << 32 | net_hash_mix(net); 226 - 227 - /* IPv4: u3.all[1,2,3] == 0 */ 228 - c ^= (u64)tuple->src.u3.all[1] << 32 | tuple->src.u3.all[2]; 229 - d += (u64)tuple->dst.u3.all[1] << 32 | tuple->dst.u3.all[2]; 230 - 231 - return (u32)siphash_4u64(a, b, c, d, &nf_conntrack_hash_rnd); 223 + return siphash((void *)tuple, 224 + offsetofend(struct nf_conntrack_tuple, dst.__nfct_hash_offsetend), 225 + &key); 232 226 } 233 227 234 228 static u32 scale_hash(u32 hash)
+4
net/netfilter/nf_conntrack_helper.c
··· 360 360 BUG_ON(me->expect_class_max >= NF_CT_MAX_EXPECT_CLASSES); 361 361 BUG_ON(strlen(me->name) > NF_CT_HELPER_NAME_LEN - 1); 362 362 363 + if (!nf_ct_helper_hash) 364 + return -ENOENT; 365 + 363 366 if (me->expect_policy->max_expected > NF_CT_EXPECT_MAX_CNT) 364 367 return -EINVAL; 365 368 ··· 518 515 void nf_conntrack_helper_fini(void) 519 516 { 520 517 kvfree(nf_ct_helper_hash); 518 + nf_ct_helper_hash = NULL; 521 519 }
+9 -1
net/netfilter/nf_conntrack_proto_gre.c
··· 205 205 enum ip_conntrack_info ctinfo, 206 206 const struct nf_hook_state *state) 207 207 { 208 + unsigned long status; 209 + 208 210 if (!nf_ct_is_confirmed(ct)) { 209 211 unsigned int *timeouts = nf_ct_timeout_lookup(ct); 210 212 ··· 219 217 ct->proto.gre.timeout = timeouts[GRE_CT_UNREPLIED]; 220 218 } 221 219 220 + status = READ_ONCE(ct->status); 222 221 /* If we've seen traffic both ways, this is a GRE connection. 223 222 * Extend timeout. */ 224 - if (ct->status & IPS_SEEN_REPLY) { 223 + if (status & IPS_SEEN_REPLY) { 225 224 nf_ct_refresh_acct(ct, ctinfo, skb, 226 225 ct->proto.gre.stream_timeout); 226 + 227 + /* never set ASSURED for IPS_NAT_CLASH, they time out soon */ 228 + if (unlikely((status & IPS_NAT_CLASH))) 229 + return NF_ACCEPT; 230 + 227 231 /* Also, more likely to be important, and not a probe. */ 228 232 if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) 229 233 nf_conntrack_event_cache(IPCT_ASSURED, ct);
+108 -66
net/netfilter/nf_tables_api.c
··· 253 253 if (chain->bound) 254 254 return -EBUSY; 255 255 256 + if (!nft_use_inc(&chain->use)) 257 + return -EMFILE; 258 + 256 259 chain->bound = true; 257 - chain->use++; 258 260 nft_chain_trans_bind(ctx, chain); 259 261 260 262 return 0; ··· 439 437 if (IS_ERR(trans)) 440 438 return PTR_ERR(trans); 441 439 442 - ctx->table->use--; 440 + nft_use_dec(&ctx->table->use); 443 441 nft_deactivate_next(ctx->net, ctx->chain); 444 442 445 443 return 0; ··· 478 476 /* You cannot delete the same rule twice */ 479 477 if (nft_is_active_next(ctx->net, rule)) { 480 478 nft_deactivate_next(ctx->net, rule); 481 - ctx->chain->use--; 479 + nft_use_dec(&ctx->chain->use); 482 480 return 0; 483 481 } 484 482 return -ENOENT; ··· 646 644 nft_map_deactivate(ctx, set); 647 645 648 646 nft_deactivate_next(ctx->net, set); 649 - ctx->table->use--; 647 + nft_use_dec(&ctx->table->use); 650 648 651 649 return err; 652 650 } ··· 678 676 return err; 679 677 680 678 nft_deactivate_next(ctx->net, obj); 681 - ctx->table->use--; 679 + nft_use_dec(&ctx->table->use); 682 680 683 681 return err; 684 682 } ··· 713 711 return err; 714 712 715 713 nft_deactivate_next(ctx->net, flowtable); 716 - ctx->table->use--; 714 + nft_use_dec(&ctx->table->use); 717 715 718 716 return err; 719 717 } ··· 2398 2396 struct nft_chain *chain; 2399 2397 int err; 2400 2398 2401 - if (table->use == UINT_MAX) 2402 - return -EOVERFLOW; 2403 - 2404 2399 if (nla[NFTA_CHAIN_HOOK]) { 2405 2400 struct nft_stats __percpu *stats = NULL; 2406 2401 struct nft_chain_hook hook = {}; ··· 2493 2494 if (err < 0) 2494 2495 goto err_destroy_chain; 2495 2496 2497 + if (!nft_use_inc(&table->use)) { 2498 + err = -EMFILE; 2499 + goto err_use; 2500 + } 2501 + 2496 2502 trans = nft_trans_chain_add(ctx, NFT_MSG_NEWCHAIN); 2497 2503 if (IS_ERR(trans)) { 2498 2504 err = PTR_ERR(trans); ··· 2514 2510 goto err_unregister_hook; 2515 2511 } 2516 2512 2517 - table->use++; 2518 - 2519 2513 return 0; 2514 + 2520 2515 err_unregister_hook: 2516 + nft_use_dec_restore(&table->use); 2517 + err_use: 2521 2518 nf_tables_unregister_hook(net, table, chain); 2522 2519 err_destroy_chain: 2523 2520 nf_tables_chain_destroy(ctx); ··· 2699 2694 2700 2695 static struct nft_chain *nft_chain_lookup_byid(const struct net *net, 2701 2696 const struct nft_table *table, 2702 - const struct nlattr *nla) 2697 + const struct nlattr *nla, u8 genmask) 2703 2698 { 2704 2699 struct nftables_pernet *nft_net = nft_pernet(net); 2705 2700 u32 id = ntohl(nla_get_be32(nla)); ··· 2710 2705 2711 2706 if (trans->msg_type == NFT_MSG_NEWCHAIN && 2712 2707 chain->table == table && 2713 - id == nft_trans_chain_id(trans)) 2708 + id == nft_trans_chain_id(trans) && 2709 + nft_active_genmask(chain, genmask)) 2714 2710 return chain; 2715 2711 } 2716 2712 return ERR_PTR(-ENOENT); ··· 3815 3809 return -EOPNOTSUPP; 3816 3810 3817 3811 } else if (nla[NFTA_RULE_CHAIN_ID]) { 3818 - chain = nft_chain_lookup_byid(net, table, nla[NFTA_RULE_CHAIN_ID]); 3812 + chain = nft_chain_lookup_byid(net, table, nla[NFTA_RULE_CHAIN_ID], 3813 + genmask); 3819 3814 if (IS_ERR(chain)) { 3820 3815 NL_SET_BAD_ATTR(extack, nla[NFTA_RULE_CHAIN_ID]); 3821 3816 return PTR_ERR(chain); ··· 3846 3839 info->nlh->nlmsg_flags & NLM_F_REPLACE) 3847 3840 return -EINVAL; 3848 3841 handle = nf_tables_alloc_handle(table); 3849 - 3850 - if (chain->use == UINT_MAX) 3851 - return -EOVERFLOW; 3852 3842 3853 3843 if (nla[NFTA_RULE_POSITION]) { 3854 3844 pos_handle = be64_to_cpu(nla_get_be64(nla[NFTA_RULE_POSITION])); ··· 3940 3936 } 3941 3937 } 3942 3938 3939 + if (!nft_use_inc(&chain->use)) { 3940 + err = -EMFILE; 3941 + goto err_release_rule; 3942 + } 3943 + 3943 3944 if (info->nlh->nlmsg_flags & NLM_F_REPLACE) { 3944 3945 err = nft_delrule(&ctx, old_rule); 3945 3946 if (err < 0) ··· 3976 3967 } 3977 3968 } 3978 3969 kvfree(expr_info); 3979 - chain->use++; 3980 3970 3981 3971 if (flow) 3982 3972 nft_trans_flow_rule(trans) = flow; ··· 3986 3978 return 0; 3987 3979 3988 3980 err_destroy_flow_rule: 3981 + nft_use_dec_restore(&chain->use); 3989 3982 if (flow) 3990 3983 nft_flow_rule_destroy(flow); 3991 3984 err_release_rule: ··· 5023 5014 alloc_size = sizeof(*set) + size + udlen; 5024 5015 if (alloc_size < size || alloc_size > INT_MAX) 5025 5016 return -ENOMEM; 5017 + 5018 + if (!nft_use_inc(&table->use)) 5019 + return -EMFILE; 5020 + 5026 5021 set = kvzalloc(alloc_size, GFP_KERNEL_ACCOUNT); 5027 - if (!set) 5028 - return -ENOMEM; 5022 + if (!set) { 5023 + err = -ENOMEM; 5024 + goto err_alloc; 5025 + } 5029 5026 5030 5027 name = nla_strdup(nla[NFTA_SET_NAME], GFP_KERNEL_ACCOUNT); 5031 5028 if (!name) { ··· 5089 5074 goto err_set_expr_alloc; 5090 5075 5091 5076 list_add_tail_rcu(&set->list, &table->sets); 5092 - table->use++; 5077 + 5093 5078 return 0; 5094 5079 5095 5080 err_set_expr_alloc: ··· 5101 5086 kfree(set->name); 5102 5087 err_set_name: 5103 5088 kvfree(set); 5089 + err_alloc: 5090 + nft_use_dec_restore(&table->use); 5091 + 5104 5092 return err; 5105 5093 } 5106 5094 ··· 5242 5224 struct nft_set_binding *i; 5243 5225 struct nft_set_iter iter; 5244 5226 5245 - if (set->use == UINT_MAX) 5246 - return -EOVERFLOW; 5247 - 5248 5227 if (!list_empty(&set->bindings) && nft_set_is_anonymous(set)) 5249 5228 return -EBUSY; 5250 5229 ··· 5269 5254 return iter.err; 5270 5255 } 5271 5256 bind: 5257 + if (!nft_use_inc(&set->use)) 5258 + return -EMFILE; 5259 + 5272 5260 binding->chain = ctx->chain; 5273 5261 list_add_tail_rcu(&binding->list, &set->bindings); 5274 5262 nft_set_trans_bind(ctx, set); 5275 - set->use++; 5276 5263 5277 5264 return 0; 5278 5265 } ··· 5348 5331 nft_clear(ctx->net, set); 5349 5332 } 5350 5333 5351 - set->use++; 5334 + nft_use_inc_restore(&set->use); 5352 5335 } 5353 5336 EXPORT_SYMBOL_GPL(nf_tables_activate_set); 5354 5337 ··· 5364 5347 else 5365 5348 list_del_rcu(&binding->list); 5366 5349 5367 - set->use--; 5350 + nft_use_dec(&set->use); 5368 5351 break; 5369 5352 case NFT_TRANS_PREPARE: 5370 5353 if (nft_set_is_anonymous(set)) { ··· 5373 5356 5374 5357 nft_deactivate_next(ctx->net, set); 5375 5358 } 5376 - set->use--; 5359 + nft_use_dec(&set->use); 5377 5360 return; 5378 5361 case NFT_TRANS_ABORT: 5379 5362 case NFT_TRANS_RELEASE: ··· 5381 5364 set->flags & (NFT_SET_MAP | NFT_SET_OBJECT)) 5382 5365 nft_map_deactivate(ctx, set); 5383 5366 5384 - set->use--; 5367 + nft_use_dec(&set->use); 5385 5368 fallthrough; 5386 5369 default: 5387 5370 nf_tables_unbind_set(ctx, set, binding, ··· 6172 6155 nft_set_elem_expr_destroy(&ctx, nft_set_ext_expr(ext)); 6173 6156 6174 6157 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF)) 6175 - (*nft_set_ext_obj(ext))->use--; 6158 + nft_use_dec(&(*nft_set_ext_obj(ext))->use); 6176 6159 kfree(elem); 6177 6160 } 6178 6161 EXPORT_SYMBOL_GPL(nft_set_elem_destroy); ··· 6674 6657 set->objtype, genmask); 6675 6658 if (IS_ERR(obj)) { 6676 6659 err = PTR_ERR(obj); 6660 + obj = NULL; 6677 6661 goto err_parse_key_end; 6678 6662 } 6663 + 6664 + if (!nft_use_inc(&obj->use)) { 6665 + err = -EMFILE; 6666 + obj = NULL; 6667 + goto err_parse_key_end; 6668 + } 6669 + 6679 6670 err = nft_set_ext_add(&tmpl, NFT_SET_EXT_OBJREF); 6680 6671 if (err < 0) 6681 6672 goto err_parse_key_end; ··· 6752 6727 if (flags) 6753 6728 *nft_set_ext_flags(ext) = flags; 6754 6729 6755 - if (obj) { 6730 + if (obj) 6756 6731 *nft_set_ext_obj(ext) = obj; 6757 - obj->use++; 6758 - } 6732 + 6759 6733 if (ulen > 0) { 6760 6734 if (nft_set_ext_check(&tmpl, NFT_SET_EXT_USERDATA, ulen) < 0) { 6761 6735 err = -EINVAL; ··· 6822 6798 kfree(trans); 6823 6799 err_elem_free: 6824 6800 nf_tables_set_elem_destroy(ctx, set, elem.priv); 6825 - if (obj) 6826 - obj->use--; 6827 6801 err_parse_data: 6828 6802 if (nla[NFTA_SET_ELEM_DATA] != NULL) 6829 6803 nft_data_release(&elem.data.val, desc.type); 6830 6804 err_parse_key_end: 6805 + if (obj) 6806 + nft_use_dec_restore(&obj->use); 6807 + 6831 6808 nft_data_release(&elem.key_end.val, NFT_DATA_VALUE); 6832 6809 err_parse_key: 6833 6810 nft_data_release(&elem.key.val, NFT_DATA_VALUE); ··· 6908 6883 case NFT_JUMP: 6909 6884 case NFT_GOTO: 6910 6885 chain = data->verdict.chain; 6911 - chain->use++; 6886 + nft_use_inc_restore(&chain->use); 6912 6887 break; 6913 6888 } 6914 6889 } ··· 6923 6898 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA)) 6924 6899 nft_data_hold(nft_set_ext_data(ext), set->dtype); 6925 6900 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF)) 6926 - (*nft_set_ext_obj(ext))->use++; 6901 + nft_use_inc_restore(&(*nft_set_ext_obj(ext))->use); 6927 6902 } 6928 6903 6929 6904 static void nft_setelem_data_deactivate(const struct net *net, ··· 6935 6910 if (nft_set_ext_exists(ext, NFT_SET_EXT_DATA)) 6936 6911 nft_data_release(nft_set_ext_data(ext), set->dtype); 6937 6912 if (nft_set_ext_exists(ext, NFT_SET_EXT_OBJREF)) 6938 - (*nft_set_ext_obj(ext))->use--; 6913 + nft_use_dec(&(*nft_set_ext_obj(ext))->use); 6939 6914 } 6940 6915 6941 6916 static int nft_del_setelem(struct nft_ctx *ctx, struct nft_set *set, ··· 7478 7453 7479 7454 nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); 7480 7455 7456 + if (!nft_use_inc(&table->use)) 7457 + return -EMFILE; 7458 + 7481 7459 type = nft_obj_type_get(net, objtype); 7482 - if (IS_ERR(type)) 7483 - return PTR_ERR(type); 7460 + if (IS_ERR(type)) { 7461 + err = PTR_ERR(type); 7462 + goto err_type; 7463 + } 7484 7464 7485 7465 obj = nft_obj_init(&ctx, type, nla[NFTA_OBJ_DATA]); 7486 7466 if (IS_ERR(obj)) { ··· 7519 7489 goto err_obj_ht; 7520 7490 7521 7491 list_add_tail_rcu(&obj->list, &table->objects); 7522 - table->use++; 7492 + 7523 7493 return 0; 7524 7494 err_obj_ht: 7525 7495 /* queued in transaction log */ ··· 7535 7505 kfree(obj); 7536 7506 err_init: 7537 7507 module_put(type->owner); 7508 + err_type: 7509 + nft_use_dec_restore(&table->use); 7510 + 7538 7511 return err; 7539 7512 } 7540 7513 ··· 7939 7906 case NFT_TRANS_PREPARE: 7940 7907 case NFT_TRANS_ABORT: 7941 7908 case NFT_TRANS_RELEASE: 7942 - flowtable->use--; 7909 + nft_use_dec(&flowtable->use); 7943 7910 fallthrough; 7944 7911 default: 7945 7912 return; ··· 8293 8260 8294 8261 nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla); 8295 8262 8263 + if (!nft_use_inc(&table->use)) 8264 + return -EMFILE; 8265 + 8296 8266 flowtable = kzalloc(sizeof(*flowtable), GFP_KERNEL_ACCOUNT); 8297 - if (!flowtable) 8298 - return -ENOMEM; 8267 + if (!flowtable) { 8268 + err = -ENOMEM; 8269 + goto flowtable_alloc; 8270 + } 8299 8271 8300 8272 flowtable->table = table; 8301 8273 flowtable->handle = nf_tables_alloc_handle(table); ··· 8355 8317 goto err5; 8356 8318 8357 8319 list_add_tail_rcu(&flowtable->list, &table->flowtables); 8358 - table->use++; 8359 8320 8360 8321 return 0; 8361 8322 err5: ··· 8371 8334 kfree(flowtable->name); 8372 8335 err1: 8373 8336 kfree(flowtable); 8337 + flowtable_alloc: 8338 + nft_use_dec_restore(&table->use); 8339 + 8374 8340 return err; 8375 8341 } 8376 8342 ··· 9753 9713 */ 9754 9714 if (nft_set_is_anonymous(nft_trans_set(trans)) && 9755 9715 !list_empty(&nft_trans_set(trans)->bindings)) 9756 - trans->ctx.table->use--; 9716 + nft_use_dec(&trans->ctx.table->use); 9757 9717 } 9758 9718 nf_tables_set_notify(&trans->ctx, nft_trans_set(trans), 9759 9719 NFT_MSG_NEWSET, GFP_KERNEL); ··· 9983 9943 nft_trans_destroy(trans); 9984 9944 break; 9985 9945 } 9986 - trans->ctx.table->use--; 9946 + nft_use_dec_restore(&trans->ctx.table->use); 9987 9947 nft_chain_del(trans->ctx.chain); 9988 9948 nf_tables_unregister_hook(trans->ctx.net, 9989 9949 trans->ctx.table, ··· 9996 9956 list_splice(&nft_trans_chain_hooks(trans), 9997 9957 &nft_trans_basechain(trans)->hook_list); 9998 9958 } else { 9999 - trans->ctx.table->use++; 9959 + nft_use_inc_restore(&trans->ctx.table->use); 10000 9960 nft_clear(trans->ctx.net, trans->ctx.chain); 10001 9961 } 10002 9962 nft_trans_destroy(trans); ··· 10006 9966 nft_trans_destroy(trans); 10007 9967 break; 10008 9968 } 10009 - trans->ctx.chain->use--; 9969 + nft_use_dec_restore(&trans->ctx.chain->use); 10010 9970 list_del_rcu(&nft_trans_rule(trans)->list); 10011 9971 nft_rule_expr_deactivate(&trans->ctx, 10012 9972 nft_trans_rule(trans), ··· 10016 9976 break; 10017 9977 case NFT_MSG_DELRULE: 10018 9978 case NFT_MSG_DESTROYRULE: 10019 - trans->ctx.chain->use++; 9979 + nft_use_inc_restore(&trans->ctx.chain->use); 10020 9980 nft_clear(trans->ctx.net, nft_trans_rule(trans)); 10021 9981 nft_rule_expr_activate(&trans->ctx, nft_trans_rule(trans)); 10022 9982 if (trans->ctx.chain->flags & NFT_CHAIN_HW_OFFLOAD) ··· 10029 9989 nft_trans_destroy(trans); 10030 9990 break; 10031 9991 } 10032 - trans->ctx.table->use--; 9992 + nft_use_dec_restore(&trans->ctx.table->use); 10033 9993 if (nft_trans_set_bound(trans)) { 10034 9994 nft_trans_destroy(trans); 10035 9995 break; ··· 10038 9998 break; 10039 9999 case NFT_MSG_DELSET: 10040 10000 case NFT_MSG_DESTROYSET: 10041 - trans->ctx.table->use++; 10001 + nft_use_inc_restore(&trans->ctx.table->use); 10042 10002 nft_clear(trans->ctx.net, nft_trans_set(trans)); 10043 10003 if (nft_trans_set(trans)->flags & (NFT_SET_MAP | NFT_SET_OBJECT)) 10044 10004 nft_map_activate(&trans->ctx, nft_trans_set(trans)); ··· 10082 10042 nft_obj_destroy(&trans->ctx, nft_trans_obj_newobj(trans)); 10083 10043 nft_trans_destroy(trans); 10084 10044 } else { 10085 - trans->ctx.table->use--; 10045 + nft_use_dec_restore(&trans->ctx.table->use); 10086 10046 nft_obj_del(nft_trans_obj(trans)); 10087 10047 } 10088 10048 break; 10089 10049 case NFT_MSG_DELOBJ: 10090 10050 case NFT_MSG_DESTROYOBJ: 10091 - trans->ctx.table->use++; 10051 + nft_use_inc_restore(&trans->ctx.table->use); 10092 10052 nft_clear(trans->ctx.net, nft_trans_obj(trans)); 10093 10053 nft_trans_destroy(trans); 10094 10054 break; ··· 10097 10057 nft_unregister_flowtable_net_hooks(net, 10098 10058 &nft_trans_flowtable_hooks(trans)); 10099 10059 } else { 10100 - trans->ctx.table->use--; 10060 + nft_use_dec_restore(&trans->ctx.table->use); 10101 10061 list_del_rcu(&nft_trans_flowtable(trans)->list); 10102 10062 nft_unregister_flowtable_net_hooks(net, 10103 10063 &nft_trans_flowtable(trans)->hook_list); ··· 10109 10069 list_splice(&nft_trans_flowtable_hooks(trans), 10110 10070 &nft_trans_flowtable(trans)->hook_list); 10111 10071 } else { 10112 - trans->ctx.table->use++; 10072 + nft_use_inc_restore(&trans->ctx.table->use); 10113 10073 nft_clear(trans->ctx.net, nft_trans_flowtable(trans)); 10114 10074 } 10115 10075 nft_trans_destroy(trans); ··· 10542 10502 genmask); 10543 10503 } else if (tb[NFTA_VERDICT_CHAIN_ID]) { 10544 10504 chain = nft_chain_lookup_byid(ctx->net, ctx->table, 10545 - tb[NFTA_VERDICT_CHAIN_ID]); 10505 + tb[NFTA_VERDICT_CHAIN_ID], 10506 + genmask); 10546 10507 if (IS_ERR(chain)) 10547 10508 return PTR_ERR(chain); 10548 10509 } else { ··· 10559 10518 if (desc->flags & NFT_DATA_DESC_SETELEM && 10560 10519 chain->flags & NFT_CHAIN_BINDING) 10561 10520 return -EINVAL; 10521 + if (!nft_use_inc(&chain->use)) 10522 + return -EMFILE; 10562 10523 10563 - chain->use++; 10564 10524 data->verdict.chain = chain; 10565 10525 break; 10566 10526 } ··· 10579 10537 case NFT_JUMP: 10580 10538 case NFT_GOTO: 10581 10539 chain = data->verdict.chain; 10582 - chain->use--; 10540 + nft_use_dec(&chain->use); 10583 10541 break; 10584 10542 } 10585 10543 } ··· 10748 10706 nf_tables_unregister_hook(ctx->net, ctx->chain->table, ctx->chain); 10749 10707 list_for_each_entry_safe(rule, nr, &ctx->chain->rules, list) { 10750 10708 list_del(&rule->list); 10751 - ctx->chain->use--; 10709 + nft_use_dec(&ctx->chain->use); 10752 10710 nf_tables_rule_release(ctx, rule); 10753 10711 } 10754 10712 nft_chain_del(ctx->chain); 10755 - ctx->table->use--; 10713 + nft_use_dec(&ctx->table->use); 10756 10714 nf_tables_chain_destroy(ctx); 10757 10715 10758 10716 return 0; ··· 10802 10760 ctx.chain = chain; 10803 10761 list_for_each_entry_safe(rule, nr, &chain->rules, list) { 10804 10762 list_del(&rule->list); 10805 - chain->use--; 10763 + nft_use_dec(&chain->use); 10806 10764 nf_tables_rule_release(&ctx, rule); 10807 10765 } 10808 10766 } 10809 10767 list_for_each_entry_safe(flowtable, nf, &table->flowtables, list) { 10810 10768 list_del(&flowtable->list); 10811 - table->use--; 10769 + nft_use_dec(&table->use); 10812 10770 nf_tables_flowtable_destroy(flowtable); 10813 10771 } 10814 10772 list_for_each_entry_safe(set, ns, &table->sets, list) { 10815 10773 list_del(&set->list); 10816 - table->use--; 10774 + nft_use_dec(&table->use); 10817 10775 if (set->flags & (NFT_SET_MAP | NFT_SET_OBJECT)) 10818 10776 nft_map_deactivate(&ctx, set); 10819 10777 ··· 10821 10779 } 10822 10780 list_for_each_entry_safe(obj, ne, &table->objects, list) { 10823 10781 nft_obj_del(obj); 10824 - table->use--; 10782 + nft_use_dec(&table->use); 10825 10783 nft_obj_destroy(&ctx, obj); 10826 10784 } 10827 10785 list_for_each_entry_safe(chain, nc, &table->chains, list) { 10828 10786 ctx.chain = chain; 10829 10787 nft_chain_del(chain); 10830 - table->use--; 10788 + nft_use_dec(&table->use); 10831 10789 nf_tables_chain_destroy(&ctx); 10832 10790 } 10833 10791 nf_tables_table_destroy(&ctx);
+7 -7
net/netfilter/nft_byteorder.c
··· 30 30 const struct nft_byteorder *priv = nft_expr_priv(expr); 31 31 u32 *src = &regs->data[priv->sreg]; 32 32 u32 *dst = &regs->data[priv->dreg]; 33 - union { u32 u32; u16 u16; } *s, *d; 33 + u16 *s16, *d16; 34 34 unsigned int i; 35 35 36 - s = (void *)src; 37 - d = (void *)dst; 36 + s16 = (void *)src; 37 + d16 = (void *)dst; 38 38 39 39 switch (priv->size) { 40 40 case 8: { ··· 62 62 switch (priv->op) { 63 63 case NFT_BYTEORDER_NTOH: 64 64 for (i = 0; i < priv->len / 4; i++) 65 - d[i].u32 = ntohl((__force __be32)s[i].u32); 65 + dst[i] = ntohl((__force __be32)src[i]); 66 66 break; 67 67 case NFT_BYTEORDER_HTON: 68 68 for (i = 0; i < priv->len / 4; i++) 69 - d[i].u32 = (__force __u32)htonl(s[i].u32); 69 + dst[i] = (__force __u32)htonl(src[i]); 70 70 break; 71 71 } 72 72 break; ··· 74 74 switch (priv->op) { 75 75 case NFT_BYTEORDER_NTOH: 76 76 for (i = 0; i < priv->len / 2; i++) 77 - d[i].u16 = ntohs((__force __be16)s[i].u16); 77 + d16[i] = ntohs((__force __be16)s16[i]); 78 78 break; 79 79 case NFT_BYTEORDER_HTON: 80 80 for (i = 0; i < priv->len / 2; i++) 81 - d[i].u16 = (__force __u16)htons(s[i].u16); 81 + d16[i] = (__force __u16)htons(s16[i]); 82 82 break; 83 83 } 84 84 break;
+4 -2
net/netfilter/nft_flow_offload.c
··· 408 408 if (IS_ERR(flowtable)) 409 409 return PTR_ERR(flowtable); 410 410 411 + if (!nft_use_inc(&flowtable->use)) 412 + return -EMFILE; 413 + 411 414 priv->flowtable = flowtable; 412 - flowtable->use++; 413 415 414 416 return nf_ct_netns_get(ctx->net, ctx->family); 415 417 } ··· 430 428 { 431 429 struct nft_flow_offload *priv = nft_expr_priv(expr); 432 430 433 - priv->flowtable->use++; 431 + nft_use_inc_restore(&priv->flowtable->use); 434 432 } 435 433 436 434 static void nft_flow_offload_destroy(const struct nft_ctx *ctx,
+4 -4
net/netfilter/nft_immediate.c
··· 159 159 default: 160 160 nft_chain_del(chain); 161 161 chain->bound = false; 162 - chain->table->use--; 162 + nft_use_dec(&chain->table->use); 163 163 break; 164 164 } 165 165 break; ··· 198 198 * let the transaction records release this chain and its rules. 199 199 */ 200 200 if (chain->bound) { 201 - chain->use--; 201 + nft_use_dec(&chain->use); 202 202 break; 203 203 } 204 204 ··· 206 206 chain_ctx = *ctx; 207 207 chain_ctx.chain = chain; 208 208 209 - chain->use--; 209 + nft_use_dec(&chain->use); 210 210 list_for_each_entry_safe(rule, n, &chain->rules, list) { 211 - chain->use--; 211 + nft_use_dec(&chain->use); 212 212 list_del(&rule->list); 213 213 nf_tables_rule_destroy(&chain_ctx, rule); 214 214 }
+5 -3
net/netfilter/nft_objref.c
··· 41 41 if (IS_ERR(obj)) 42 42 return -ENOENT; 43 43 44 + if (!nft_use_inc(&obj->use)) 45 + return -EMFILE; 46 + 44 47 nft_objref_priv(expr) = obj; 45 - obj->use++; 46 48 47 49 return 0; 48 50 } ··· 74 72 if (phase == NFT_TRANS_COMMIT) 75 73 return; 76 74 77 - obj->use--; 75 + nft_use_dec(&obj->use); 78 76 } 79 77 80 78 static void nft_objref_activate(const struct nft_ctx *ctx, ··· 82 80 { 83 81 struct nft_object *obj = nft_objref_priv(expr); 84 82 85 - obj->use++; 83 + nft_use_inc_restore(&obj->use); 86 84 } 87 85 88 86 static const struct nft_expr_ops nft_objref_ops = {
+1 -1
net/sched/act_api.c
··· 1320 1320 return ERR_PTR(err); 1321 1321 } 1322 1322 } else { 1323 - if (strlcpy(act_name, "police", IFNAMSIZ) >= IFNAMSIZ) { 1323 + if (strscpy(act_name, "police", IFNAMSIZ) < 0) { 1324 1324 NL_SET_ERR_MSG(extack, "TC action name too long"); 1325 1325 return ERR_PTR(-EINVAL); 1326 1326 }
+10
net/sched/cls_flower.c
··· 812 812 TCA_FLOWER_KEY_PORT_SRC_MAX, &mask->tp_range.tp_max.src, 813 813 TCA_FLOWER_UNSPEC, sizeof(key->tp_range.tp_max.src)); 814 814 815 + if (mask->tp_range.tp_min.dst != mask->tp_range.tp_max.dst) { 816 + NL_SET_ERR_MSG(extack, 817 + "Both min and max destination ports must be specified"); 818 + return -EINVAL; 819 + } 820 + if (mask->tp_range.tp_min.src != mask->tp_range.tp_max.src) { 821 + NL_SET_ERR_MSG(extack, 822 + "Both min and max source ports must be specified"); 823 + return -EINVAL; 824 + } 815 825 if (mask->tp_range.tp_min.dst && mask->tp_range.tp_max.dst && 816 826 ntohs(key->tp_range.tp_max.dst) <= 817 827 ntohs(key->tp_range.tp_min.dst)) {
+5 -5
net/sched/cls_fw.c
··· 212 212 if (err < 0) 213 213 return err; 214 214 215 - if (tb[TCA_FW_CLASSID]) { 216 - f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); 217 - tcf_bind_filter(tp, &f->res, base); 218 - } 219 - 220 215 if (tb[TCA_FW_INDEV]) { 221 216 int ret; 222 217 ret = tcf_change_indev(net, tb[TCA_FW_INDEV], extack); ··· 227 232 return err; 228 233 } else if (head->mask != 0xFFFFFFFF) 229 234 return err; 235 + 236 + if (tb[TCA_FW_CLASSID]) { 237 + f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]); 238 + tcf_bind_filter(tp, &f->res, base); 239 + } 230 240 231 241 return 0; 232 242 }
+15 -3
net/sched/sch_qfq.c
··· 381 381 u32 lmax) 382 382 { 383 383 struct qfq_sched *q = qdisc_priv(sch); 384 - struct qfq_aggregate *new_agg = qfq_find_agg(q, lmax, weight); 384 + struct qfq_aggregate *new_agg; 385 385 386 + /* 'lmax' can range from [QFQ_MIN_LMAX, pktlen + stab overhead] */ 387 + if (lmax > QFQ_MAX_LMAX) 388 + return -EINVAL; 389 + 390 + new_agg = qfq_find_agg(q, lmax, weight); 386 391 if (new_agg == NULL) { /* create new aggregate */ 387 392 new_agg = kzalloc(sizeof(*new_agg), GFP_ATOMIC); 388 393 if (new_agg == NULL) ··· 428 423 else 429 424 weight = 1; 430 425 431 - if (tb[TCA_QFQ_LMAX]) 426 + if (tb[TCA_QFQ_LMAX]) { 432 427 lmax = nla_get_u32(tb[TCA_QFQ_LMAX]); 433 - else 428 + } else { 429 + /* MTU size is user controlled */ 434 430 lmax = psched_mtu(qdisc_dev(sch)); 431 + if (lmax < QFQ_MIN_LMAX || lmax > QFQ_MAX_LMAX) { 432 + NL_SET_ERR_MSG_MOD(extack, 433 + "MTU size out of bounds for qfq"); 434 + return -EINVAL; 435 + } 436 + } 435 437 436 438 inv_w = ONE_FP / weight; 437 439 weight = ONE_FP / inv_w;
+2
net/wireless/util.c
··· 580 580 hdrlen += ETH_ALEN + 2; 581 581 else if (!pskb_may_pull(skb, hdrlen)) 582 582 return -EINVAL; 583 + else 584 + payload.eth.h_proto = htons(skb->len - hdrlen); 583 585 584 586 mesh_addr = skb->data + sizeof(payload.eth) + ETH_ALEN; 585 587 switch (payload.flags & MESH_FLAGS_AE) {
+9
tools/testing/selftests/bpf/prog_tests/async_stack_depth.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <test_progs.h> 3 + 4 + #include "async_stack_depth.skel.h" 5 + 6 + void test_async_stack_depth(void) 7 + { 8 + RUN_TESTS(async_stack_depth); 9 + }
+40
tools/testing/selftests/bpf/progs/async_stack_depth.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + #include <vmlinux.h> 3 + #include <bpf/bpf_helpers.h> 4 + 5 + #include "bpf_misc.h" 6 + 7 + struct hmap_elem { 8 + struct bpf_timer timer; 9 + }; 10 + 11 + struct { 12 + __uint(type, BPF_MAP_TYPE_HASH); 13 + __uint(max_entries, 64); 14 + __type(key, int); 15 + __type(value, struct hmap_elem); 16 + } hmap SEC(".maps"); 17 + 18 + __attribute__((noinline)) 19 + static int timer_cb(void *map, int *key, struct bpf_timer *timer) 20 + { 21 + volatile char buf[256] = {}; 22 + return buf[69]; 23 + } 24 + 25 + SEC("tc") 26 + __failure __msg("combined stack size of 2 calls") 27 + int prog(struct __sk_buff *ctx) 28 + { 29 + struct hmap_elem *elem; 30 + volatile char buf[256] = {}; 31 + 32 + elem = bpf_map_lookup_elem(&hmap, &(int){0}); 33 + if (!elem) 34 + return 0; 35 + 36 + timer_cb(NULL, NULL, NULL); 37 + return bpf_timer_set_callback(&elem->timer, timer_cb) + buf[0]; 38 + } 39 + 40 + char _license[] SEC("license") = "GPL";
+86
tools/testing/selftests/tc-testing/tc-tests/qdiscs/qfq.json
··· 213 213 "$TC qdisc del dev $DUMMY handle 1: root", 214 214 "$IP link del dev $DUMMY type dummy" 215 215 ] 216 + }, 217 + { 218 + "id": "85ee", 219 + "name": "QFQ with big MTU", 220 + "category": [ 221 + "qdisc", 222 + "qfq" 223 + ], 224 + "plugins": { 225 + "requires": "nsPlugin" 226 + }, 227 + "setup": [ 228 + "$IP link add dev $DUMMY type dummy || /bin/true", 229 + "$IP link set dev $DUMMY mtu 2147483647 || /bin/true", 230 + "$TC qdisc add dev $DUMMY handle 1: root qfq" 231 + ], 232 + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100", 233 + "expExitCode": "2", 234 + "verifyCmd": "$TC class show dev $DUMMY", 235 + "matchPattern": "class qfq 1:", 236 + "matchCount": "0", 237 + "teardown": [ 238 + "$IP link del dev $DUMMY type dummy" 239 + ] 240 + }, 241 + { 242 + "id": "ddfa", 243 + "name": "QFQ with small MTU", 244 + "category": [ 245 + "qdisc", 246 + "qfq" 247 + ], 248 + "plugins": { 249 + "requires": "nsPlugin" 250 + }, 251 + "setup": [ 252 + "$IP link add dev $DUMMY type dummy || /bin/true", 253 + "$IP link set dev $DUMMY mtu 256 || /bin/true", 254 + "$TC qdisc add dev $DUMMY handle 1: root qfq" 255 + ], 256 + "cmdUnderTest": "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100", 257 + "expExitCode": "2", 258 + "verifyCmd": "$TC class show dev $DUMMY", 259 + "matchPattern": "class qfq 1:", 260 + "matchCount": "0", 261 + "teardown": [ 262 + "$IP link del dev $DUMMY type dummy" 263 + ] 264 + }, 265 + { 266 + "id": "5993", 267 + "name": "QFQ with stab overhead greater than max packet len", 268 + "category": [ 269 + "qdisc", 270 + "qfq", 271 + "scapy" 272 + ], 273 + "plugins": { 274 + "requires": [ 275 + "nsPlugin", 276 + "scapyPlugin" 277 + ] 278 + }, 279 + "setup": [ 280 + "$IP link add dev $DUMMY type dummy || /bin/true", 281 + "$IP link set dev $DUMMY up || /bin/true", 282 + "$TC qdisc add dev $DUMMY handle 1: stab mtu 2048 tsize 512 mpu 0 overhead 999999999 linklayer ethernet root qfq", 283 + "$TC class add dev $DUMMY parent 1: classid 1:1 qfq weight 100", 284 + "$TC qdisc add dev $DEV1 clsact", 285 + "$TC filter add dev $DEV1 ingress protocol ip flower dst_ip 1.3.3.7/32 action mirred egress mirror dev $DUMMY" 286 + ], 287 + "cmdUnderTest": "$TC filter add dev $DUMMY parent 1: matchall classid 1:1", 288 + "scapy": [ 289 + { 290 + "iface": "$DEV0", 291 + "count": 22, 292 + "packet": "Ether(type=0x800)/IP(src='10.0.0.10',dst='1.3.3.7')/TCP(sport=5000,dport=10)" 293 + } 294 + ], 295 + "expExitCode": "0", 296 + "verifyCmd": "$TC -s qdisc ls dev $DUMMY", 297 + "matchPattern": "dropped 22", 298 + "matchCount": "1", 299 + "teardown": [ 300 + "$TC qdisc del dev $DUMMY handle 1: root qfq" 301 + ] 216 302 } 217 303 ]