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

Configure Feed

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

Merge branch 'add-more-feautues-for-enetc-v4-round-1'

Wei Fang says:

====================
Add more feautues for ENETC v4 - round 1

Compared to ENETC v1 (LS1028A), ENETC v4 (i.MX95) adds more features, and
some features are configured completely differently from v1. In order to
more fully support ENETC v4, these features will be added through several
rounds of patch sets. This round adds these features, such as Tx and Rx
checksum offload, increase maximum chained Tx BD number and Large send
offload (LSO).

v1 Link: https://lore.kernel.org/20241107033817.1654163-1-wei.fang@nxp.com
v2 Link: https://lore.kernel.org/20241111015216.1804534-1-wei.fang@nxp.com
v3 Link: https://lore.kernel.org/20241112091447.1850899-1-wei.fang@nxp.com
v4 Link: https://lore.kernel.org/20241115024744.1903377-1-wei.fang@nxp.com
v5 Link: https://lore.kernel.org/20241118060630.1956134-1-wei.fang@nxp.com
v6 Link: https://lore.kernel.org/20241119082344.2022830-1-wei.fang@nxp.com
v6 RESEND Link: https://lore.kernel.org/20241204052932.112446-1-wei.fang@nxp.com
v7 Link: https://lore.kernel.org/20241211063752.744975-1-wei.fang@nxp.com
v8 Link: https://lore.kernel.org/20241213021731.1157535-1-wei.fang@nxp.com
====================

Link: https://patch.msgid.link/20241219054755.1615626-1-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+403 -30
+312 -18
drivers/net/ethernet/freescale/enetc/enetc.c
··· 146 146 return 0; 147 147 } 148 148 149 + static bool enetc_tx_csum_offload_check(struct sk_buff *skb) 150 + { 151 + switch (skb->csum_offset) { 152 + case offsetof(struct tcphdr, check): 153 + case offsetof(struct udphdr, check): 154 + return true; 155 + default: 156 + return false; 157 + } 158 + } 159 + 160 + static bool enetc_skb_is_ipv6(struct sk_buff *skb) 161 + { 162 + return vlan_get_protocol(skb) == htons(ETH_P_IPV6); 163 + } 164 + 165 + static bool enetc_skb_is_tcp(struct sk_buff *skb) 166 + { 167 + return skb->csum_offset == offsetof(struct tcphdr, check); 168 + } 169 + 149 170 static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) 150 171 { 151 172 bool do_vlan, do_onestep_tstamp = false, do_twostep_tstamp = false; ··· 184 163 dma_addr_t dma; 185 164 u8 flags = 0; 186 165 166 + enetc_clear_tx_bd(&temp_bd); 167 + if (skb->ip_summed == CHECKSUM_PARTIAL) { 168 + /* Can not support TSD and checksum offload at the same time */ 169 + if (priv->active_offloads & ENETC_F_TXCSUM && 170 + enetc_tx_csum_offload_check(skb) && !tx_ring->tsd_enable) { 171 + temp_bd.l3_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, 172 + skb_network_offset(skb)); 173 + temp_bd.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, 174 + skb_network_header_len(skb) / 4); 175 + temp_bd.l3_aux1 |= FIELD_PREP(ENETC_TX_BD_L3T, 176 + enetc_skb_is_ipv6(skb)); 177 + if (enetc_skb_is_tcp(skb)) 178 + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, 179 + ENETC_TXBD_L4T_TCP); 180 + else 181 + temp_bd.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, 182 + ENETC_TXBD_L4T_UDP); 183 + flags |= ENETC_TXBD_FLAGS_CSUM_LSO | ENETC_TXBD_FLAGS_L4CS; 184 + } else if (skb_checksum_help(skb)) { 185 + return 0; 186 + } 187 + } 188 + 187 189 i = tx_ring->next_to_use; 188 190 txbd = ENETC_TXBD(*tx_ring, i); 189 191 prefetchw(txbd); ··· 217 173 218 174 temp_bd.addr = cpu_to_le64(dma); 219 175 temp_bd.buf_len = cpu_to_le16(len); 220 - temp_bd.lstatus = 0; 221 176 222 177 tx_swbd = &tx_ring->tx_swbd[i]; 223 178 tx_swbd->dma = dma; ··· 532 489 } 533 490 } 534 491 492 + static int enetc_lso_count_descs(const struct sk_buff *skb) 493 + { 494 + /* 4 BDs: 1 BD for LSO header + 1 BD for extended BD + 1 BD 495 + * for linear area data but not include LSO header, namely 496 + * skb_headlen(skb) - lso_hdr_len (it may be 0, but that's 497 + * okay, we only need to consider the worst case). And 1 BD 498 + * for gap. 499 + */ 500 + return skb_shinfo(skb)->nr_frags + 4; 501 + } 502 + 503 + static int enetc_lso_get_hdr_len(const struct sk_buff *skb) 504 + { 505 + int hdr_len, tlen; 506 + 507 + tlen = skb_is_gso_tcp(skb) ? tcp_hdrlen(skb) : sizeof(struct udphdr); 508 + hdr_len = skb_transport_offset(skb) + tlen; 509 + 510 + return hdr_len; 511 + } 512 + 513 + static void enetc_lso_start(struct sk_buff *skb, struct enetc_lso_t *lso) 514 + { 515 + lso->lso_seg_size = skb_shinfo(skb)->gso_size; 516 + lso->ipv6 = enetc_skb_is_ipv6(skb); 517 + lso->tcp = skb_is_gso_tcp(skb); 518 + lso->l3_hdr_len = skb_network_header_len(skb); 519 + lso->l3_start = skb_network_offset(skb); 520 + lso->hdr_len = enetc_lso_get_hdr_len(skb); 521 + lso->total_len = skb->len - lso->hdr_len; 522 + } 523 + 524 + static void enetc_lso_map_hdr(struct enetc_bdr *tx_ring, struct sk_buff *skb, 525 + int *i, struct enetc_lso_t *lso) 526 + { 527 + union enetc_tx_bd txbd_tmp, *txbd; 528 + struct enetc_tx_swbd *tx_swbd; 529 + u16 frm_len, frm_len_ext; 530 + u8 flags, e_flags = 0; 531 + dma_addr_t addr; 532 + char *hdr; 533 + 534 + /* Get the first BD of the LSO BDs chain */ 535 + txbd = ENETC_TXBD(*tx_ring, *i); 536 + tx_swbd = &tx_ring->tx_swbd[*i]; 537 + prefetchw(txbd); 538 + 539 + /* Prepare LSO header: MAC + IP + TCP/UDP */ 540 + hdr = tx_ring->tso_headers + *i * TSO_HEADER_SIZE; 541 + memcpy(hdr, skb->data, lso->hdr_len); 542 + addr = tx_ring->tso_headers_dma + *i * TSO_HEADER_SIZE; 543 + 544 + /* {frm_len_ext, frm_len} indicates the total length of 545 + * large transmit data unit. frm_len contains the 16 least 546 + * significant bits and frm_len_ext contains the 4 most 547 + * significant bits. 548 + */ 549 + frm_len = lso->total_len & 0xffff; 550 + frm_len_ext = (lso->total_len >> 16) & 0xf; 551 + 552 + /* Set the flags of the first BD */ 553 + flags = ENETC_TXBD_FLAGS_EX | ENETC_TXBD_FLAGS_CSUM_LSO | 554 + ENETC_TXBD_FLAGS_LSO | ENETC_TXBD_FLAGS_L4CS; 555 + 556 + enetc_clear_tx_bd(&txbd_tmp); 557 + txbd_tmp.addr = cpu_to_le64(addr); 558 + txbd_tmp.hdr_len = cpu_to_le16(lso->hdr_len); 559 + 560 + /* first BD needs frm_len and offload flags set */ 561 + txbd_tmp.frm_len = cpu_to_le16(frm_len); 562 + txbd_tmp.flags = flags; 563 + 564 + txbd_tmp.l3_aux0 = FIELD_PREP(ENETC_TX_BD_L3_START, lso->l3_start); 565 + /* l3_hdr_size in 32-bits (4 bytes) */ 566 + txbd_tmp.l3_aux1 = FIELD_PREP(ENETC_TX_BD_L3_HDR_LEN, 567 + lso->l3_hdr_len / 4); 568 + if (lso->ipv6) 569 + txbd_tmp.l3_aux1 |= ENETC_TX_BD_L3T; 570 + else 571 + txbd_tmp.l3_aux0 |= ENETC_TX_BD_IPCS; 572 + 573 + txbd_tmp.l4_aux = FIELD_PREP(ENETC_TX_BD_L4T, lso->tcp ? 574 + ENETC_TXBD_L4T_TCP : ENETC_TXBD_L4T_UDP); 575 + 576 + /* For the LSO header we do not set the dma address since 577 + * we do not want it unmapped when we do cleanup. We still 578 + * set len so that we count the bytes sent. 579 + */ 580 + tx_swbd->len = lso->hdr_len; 581 + tx_swbd->do_twostep_tstamp = false; 582 + tx_swbd->check_wb = false; 583 + 584 + /* Actually write the header in the BD */ 585 + *txbd = txbd_tmp; 586 + 587 + /* Get the next BD, and the next BD is extended BD */ 588 + enetc_bdr_idx_inc(tx_ring, i); 589 + txbd = ENETC_TXBD(*tx_ring, *i); 590 + tx_swbd = &tx_ring->tx_swbd[*i]; 591 + prefetchw(txbd); 592 + 593 + enetc_clear_tx_bd(&txbd_tmp); 594 + if (skb_vlan_tag_present(skb)) { 595 + /* Setup the VLAN fields */ 596 + txbd_tmp.ext.vid = cpu_to_le16(skb_vlan_tag_get(skb)); 597 + txbd_tmp.ext.tpid = ENETC_TPID_8021Q; 598 + e_flags = ENETC_TXBD_E_FLAGS_VLAN_INS; 599 + } 600 + 601 + /* Write the BD */ 602 + txbd_tmp.ext.e_flags = e_flags; 603 + txbd_tmp.ext.lso_sg_size = cpu_to_le16(lso->lso_seg_size); 604 + txbd_tmp.ext.frm_len_ext = cpu_to_le16(frm_len_ext); 605 + *txbd = txbd_tmp; 606 + } 607 + 608 + static int enetc_lso_map_data(struct enetc_bdr *tx_ring, struct sk_buff *skb, 609 + int *i, struct enetc_lso_t *lso, int *count) 610 + { 611 + union enetc_tx_bd txbd_tmp, *txbd = NULL; 612 + struct enetc_tx_swbd *tx_swbd; 613 + skb_frag_t *frag; 614 + dma_addr_t dma; 615 + u8 flags = 0; 616 + int len, f; 617 + 618 + len = skb_headlen(skb) - lso->hdr_len; 619 + if (len > 0) { 620 + dma = dma_map_single(tx_ring->dev, skb->data + lso->hdr_len, 621 + len, DMA_TO_DEVICE); 622 + if (dma_mapping_error(tx_ring->dev, dma)) 623 + return -ENOMEM; 624 + 625 + enetc_bdr_idx_inc(tx_ring, i); 626 + txbd = ENETC_TXBD(*tx_ring, *i); 627 + tx_swbd = &tx_ring->tx_swbd[*i]; 628 + prefetchw(txbd); 629 + *count += 1; 630 + 631 + enetc_clear_tx_bd(&txbd_tmp); 632 + txbd_tmp.addr = cpu_to_le64(dma); 633 + txbd_tmp.buf_len = cpu_to_le16(len); 634 + 635 + tx_swbd->dma = dma; 636 + tx_swbd->len = len; 637 + tx_swbd->is_dma_page = 0; 638 + tx_swbd->dir = DMA_TO_DEVICE; 639 + } 640 + 641 + frag = &skb_shinfo(skb)->frags[0]; 642 + for (f = 0; f < skb_shinfo(skb)->nr_frags; f++, frag++) { 643 + if (txbd) 644 + *txbd = txbd_tmp; 645 + 646 + len = skb_frag_size(frag); 647 + dma = skb_frag_dma_map(tx_ring->dev, frag); 648 + if (dma_mapping_error(tx_ring->dev, dma)) 649 + return -ENOMEM; 650 + 651 + /* Get the next BD */ 652 + enetc_bdr_idx_inc(tx_ring, i); 653 + txbd = ENETC_TXBD(*tx_ring, *i); 654 + tx_swbd = &tx_ring->tx_swbd[*i]; 655 + prefetchw(txbd); 656 + *count += 1; 657 + 658 + enetc_clear_tx_bd(&txbd_tmp); 659 + txbd_tmp.addr = cpu_to_le64(dma); 660 + txbd_tmp.buf_len = cpu_to_le16(len); 661 + 662 + tx_swbd->dma = dma; 663 + tx_swbd->len = len; 664 + tx_swbd->is_dma_page = 1; 665 + tx_swbd->dir = DMA_TO_DEVICE; 666 + } 667 + 668 + /* Last BD needs 'F' bit set */ 669 + flags |= ENETC_TXBD_FLAGS_F; 670 + txbd_tmp.flags = flags; 671 + *txbd = txbd_tmp; 672 + 673 + tx_swbd->is_eof = 1; 674 + tx_swbd->skb = skb; 675 + 676 + return 0; 677 + } 678 + 679 + static int enetc_lso_hw_offload(struct enetc_bdr *tx_ring, struct sk_buff *skb) 680 + { 681 + struct enetc_tx_swbd *tx_swbd; 682 + struct enetc_lso_t lso = {0}; 683 + int err, i, count = 0; 684 + 685 + /* Initialize the LSO handler */ 686 + enetc_lso_start(skb, &lso); 687 + i = tx_ring->next_to_use; 688 + 689 + enetc_lso_map_hdr(tx_ring, skb, &i, &lso); 690 + /* First BD and an extend BD */ 691 + count += 2; 692 + 693 + err = enetc_lso_map_data(tx_ring, skb, &i, &lso, &count); 694 + if (err) 695 + goto dma_err; 696 + 697 + /* Go to the next BD */ 698 + enetc_bdr_idx_inc(tx_ring, &i); 699 + tx_ring->next_to_use = i; 700 + enetc_update_tx_ring_tail(tx_ring); 701 + 702 + return count; 703 + 704 + dma_err: 705 + do { 706 + tx_swbd = &tx_ring->tx_swbd[i]; 707 + enetc_free_tx_frame(tx_ring, tx_swbd); 708 + if (i == 0) 709 + i = tx_ring->bd_count; 710 + i--; 711 + } while (--count); 712 + 713 + return 0; 714 + } 715 + 535 716 static int enetc_map_tx_tso_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb) 536 717 { 718 + struct enetc_ndev_priv *priv = netdev_priv(tx_ring->ndev); 537 719 int hdr_len, total_len, data_len; 538 720 struct enetc_tx_swbd *tx_swbd; 539 721 union enetc_tx_bd *txbd; ··· 824 556 bd_data_num++; 825 557 tso_build_data(skb, &tso, size); 826 558 827 - if (unlikely(bd_data_num >= ENETC_MAX_SKB_FRAGS && data_len)) 559 + if (unlikely(bd_data_num >= priv->max_frags && data_len)) 828 560 goto err_chained_bd; 829 561 } 830 562 ··· 862 594 { 863 595 struct enetc_ndev_priv *priv = netdev_priv(ndev); 864 596 struct enetc_bdr *tx_ring; 865 - int count, err; 597 + int count; 866 598 867 599 /* Queue one-step Sync packet if already locked */ 868 600 if (skb->cb[0] & ENETC_F_TX_ONESTEP_SYNC_TSTAMP) { ··· 876 608 tx_ring = priv->tx_ring[skb->queue_mapping]; 877 609 878 610 if (skb_is_gso(skb)) { 879 - if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { 880 - netif_stop_subqueue(ndev, tx_ring->index); 881 - return NETDEV_TX_BUSY; 882 - } 611 + /* LSO data unit lengths of up to 256KB are supported */ 612 + if (priv->active_offloads & ENETC_F_LSO && 613 + (skb->len - enetc_lso_get_hdr_len(skb)) <= 614 + ENETC_LSO_MAX_DATA_LEN) { 615 + if (enetc_bd_unused(tx_ring) < enetc_lso_count_descs(skb)) { 616 + netif_stop_subqueue(ndev, tx_ring->index); 617 + return NETDEV_TX_BUSY; 618 + } 883 619 884 - enetc_lock_mdio(); 885 - count = enetc_map_tx_tso_buffs(tx_ring, skb); 886 - enetc_unlock_mdio(); 620 + count = enetc_lso_hw_offload(tx_ring, skb); 621 + } else { 622 + if (enetc_bd_unused(tx_ring) < tso_count_descs(skb)) { 623 + netif_stop_subqueue(ndev, tx_ring->index); 624 + return NETDEV_TX_BUSY; 625 + } 626 + 627 + enetc_lock_mdio(); 628 + count = enetc_map_tx_tso_buffs(tx_ring, skb); 629 + enetc_unlock_mdio(); 630 + } 887 631 } else { 888 - if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS)) 632 + if (unlikely(skb_shinfo(skb)->nr_frags > priv->max_frags)) 889 633 if (unlikely(skb_linearize(skb))) 890 634 goto drop_packet_err; 891 635 ··· 907 627 return NETDEV_TX_BUSY; 908 628 } 909 629 910 - if (skb->ip_summed == CHECKSUM_PARTIAL) { 911 - err = skb_checksum_help(skb); 912 - if (err) 913 - goto drop_packet_err; 914 - } 915 630 enetc_lock_mdio(); 916 631 count = enetc_map_tx_buffs(tx_ring, skb); 917 632 enetc_unlock_mdio(); ··· 915 640 if (unlikely(!count)) 916 641 goto drop_packet_err; 917 642 918 - if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED) 643 + if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED(priv->max_frags)) 919 644 netif_stop_subqueue(ndev, tx_ring->index); 920 645 921 646 return NETDEV_TX_OK; ··· 1183 908 if (unlikely(tx_frm_cnt && netif_carrier_ok(ndev) && 1184 909 __netif_subqueue_stopped(ndev, tx_ring->index) && 1185 910 !test_bit(ENETC_TX_DOWN, &priv->flags) && 1186 - (enetc_bd_unused(tx_ring) >= ENETC_TXBDS_MAX_NEEDED))) { 911 + (enetc_bd_unused(tx_ring) >= 912 + ENETC_TXBDS_MAX_NEEDED(priv->max_frags)))) { 1187 913 netif_wake_subqueue(ndev, tx_ring->index); 1188 914 } 1189 915 ··· 2035 1759 rss = enetc_rd(hw, ENETC_SIRSSCAPR); 2036 1760 si->num_rss = ENETC_SIRSSCAPR_GET_NUM_RSS(rss); 2037 1761 } 1762 + 1763 + if (val & ENETC_SIPCAPR0_LSO) 1764 + si->hw_features |= ENETC_SI_F_LSO; 2038 1765 } 2039 1766 EXPORT_SYMBOL_GPL(enetc_get_si_caps); 2040 1767 ··· 2334 2055 return 0; 2335 2056 } 2336 2057 2058 + static void enetc_set_lso_flags_mask(struct enetc_hw *hw) 2059 + { 2060 + enetc_wr(hw, ENETC4_SILSOSFMR0, 2061 + SILSOSFMR0_VAL_SET(ENETC4_TCP_NL_SEG_FLAGS_DMASK, 2062 + ENETC4_TCP_NL_SEG_FLAGS_DMASK)); 2063 + enetc_wr(hw, ENETC4_SILSOSFMR1, 0); 2064 + } 2065 + 2337 2066 int enetc_configure_si(struct enetc_ndev_priv *priv) 2338 2067 { 2339 2068 struct enetc_si *si = priv->si; ··· 2354 2067 enetc_wr(hw, ENETC_SICAR1, ENETC_SICAR_MSI); 2355 2068 /* enable SI */ 2356 2069 enetc_wr(hw, ENETC_SIMR, ENETC_SIMR_EN); 2070 + 2071 + if (si->hw_features & ENETC_SI_F_LSO) 2072 + enetc_set_lso_flags_mask(hw); 2357 2073 2358 2074 /* TODO: RSS support for i.MX95 will be supported later, and the 2359 2075 * is_enetc_rev1() condition will be removed ··· 3559 3269 static const struct enetc_drvdata enetc_pf_data = { 3560 3270 .sysclk_freq = ENETC_CLK_400M, 3561 3271 .pmac_offset = ENETC_PMAC_OFFSET, 3272 + .max_frags = ENETC_MAX_SKB_FRAGS, 3562 3273 .eth_ops = &enetc_pf_ethtool_ops, 3563 3274 }; 3564 3275 3565 3276 static const struct enetc_drvdata enetc4_pf_data = { 3566 3277 .sysclk_freq = ENETC_CLK_333M, 3278 + .tx_csum = true, 3279 + .max_frags = ENETC4_MAX_SKB_FRAGS, 3567 3280 .pmac_offset = ENETC4_PMAC_OFFSET, 3568 3281 .eth_ops = &enetc4_pf_ethtool_ops, 3569 3282 }; 3570 3283 3571 3284 static const struct enetc_drvdata enetc_vf_data = { 3572 3285 .sysclk_freq = ENETC_CLK_400M, 3286 + .max_frags = ENETC_MAX_SKB_FRAGS, 3573 3287 .eth_ops = &enetc_vf_ethtool_ops, 3574 3288 }; 3575 3289
+27 -2
drivers/net/ethernet/freescale/enetc/enetc.h
··· 41 41 u8 qbv_en:1; 42 42 }; 43 43 44 + struct enetc_lso_t { 45 + bool ipv6; 46 + bool tcp; 47 + u8 l3_hdr_len; 48 + u8 hdr_len; /* LSO header length */ 49 + u8 l3_start; 50 + u16 lso_seg_size; 51 + int total_len; /* total data length, not include LSO header */ 52 + }; 53 + 54 + #define ENETC_LSO_MAX_DATA_LEN SZ_256K 55 + 44 56 #define ENETC_RX_MAXFRM_SIZE ENETC_MAC_MAXFRM_SIZE 45 57 #define ENETC_RXB_TRUESIZE 2048 /* PAGE_SIZE >> 1 */ 46 58 #define ENETC_RXB_PAD NET_SKB_PAD /* add extra space if needed */ ··· 71 59 72 60 /* ENETC overhead: optional extension BD + 1 BD gap */ 73 61 #define ENETC_TXBDS_NEEDED(val) ((val) + 2) 74 - /* max # of chained Tx BDs is 15, including head and extension BD */ 62 + /* For LS1028A, max # of chained Tx BDs is 15, including head and 63 + * extension BD. 64 + */ 75 65 #define ENETC_MAX_SKB_FRAGS 13 76 - #define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1) 66 + /* For ENETC v4 and later versions, max # of chained Tx BDs is 63, 67 + * including head and extension BD, but the range of MAX_SKB_FRAGS 68 + * is 17 ~ 45, so set ENETC4_MAX_SKB_FRAGS to MAX_SKB_FRAGS. 69 + */ 70 + #define ENETC4_MAX_SKB_FRAGS MAX_SKB_FRAGS 71 + #define ENETC_TXBDS_MAX_NEEDED(x) ENETC_TXBDS_NEEDED((x) + 1) 77 72 78 73 struct enetc_ring_stats { 79 74 unsigned int packets; ··· 250 231 #define ENETC_SI_F_PSFP BIT(0) 251 232 #define ENETC_SI_F_QBV BIT(1) 252 233 #define ENETC_SI_F_QBU BIT(2) 234 + #define ENETC_SI_F_LSO BIT(3) 253 235 254 236 struct enetc_drvdata { 255 237 u32 pmac_offset; /* Only valid for PSI which supports 802.1Qbu */ 238 + u8 tx_csum:1; 239 + u8 max_frags; 256 240 u64 sysclk_freq; 257 241 const struct ethtool_ops *eth_ops; 258 242 }; ··· 363 341 ENETC_F_QBV = BIT(9), 364 342 ENETC_F_QCI = BIT(10), 365 343 ENETC_F_QBU = BIT(11), 344 + ENETC_F_TXCSUM = BIT(12), 345 + ENETC_F_LSO = BIT(13), 366 346 }; 367 347 368 348 enum enetc_flags_bit { ··· 399 375 u16 msg_enable; 400 376 401 377 u8 preemptible_tcs; 378 + u8 max_frags; /* The maximum number of BDs for fragments */ 402 379 403 380 enum enetc_active_offloads active_offloads; 404 381
+23
drivers/net/ethernet/freescale/enetc/enetc4_hw.h
··· 12 12 #define NXP_ENETC_VENDOR_ID 0x1131 13 13 #define NXP_ENETC_PF_DEV_ID 0xe101 14 14 15 + /**********************Station interface registers************************/ 16 + /* Station interface LSO segmentation flag mask register 0/1 */ 17 + #define ENETC4_SILSOSFMR0 0x1300 18 + #define SILSOSFMR0_TCP_MID_SEG GENMASK(27, 16) 19 + #define SILSOSFMR0_TCP_1ST_SEG GENMASK(11, 0) 20 + #define SILSOSFMR0_VAL_SET(first, mid) (FIELD_PREP(SILSOSFMR0_TCP_MID_SEG, mid) | \ 21 + FIELD_PREP(SILSOSFMR0_TCP_1ST_SEG, first)) 22 + 23 + #define ENETC4_SILSOSFMR1 0x1304 24 + #define SILSOSFMR1_TCP_LAST_SEG GENMASK(11, 0) 25 + #define ENETC4_TCP_FLAGS_FIN BIT(0) 26 + #define ENETC4_TCP_FLAGS_SYN BIT(1) 27 + #define ENETC4_TCP_FLAGS_RST BIT(2) 28 + #define ENETC4_TCP_FLAGS_PSH BIT(3) 29 + #define ENETC4_TCP_FLAGS_ACK BIT(4) 30 + #define ENETC4_TCP_FLAGS_URG BIT(5) 31 + #define ENETC4_TCP_FLAGS_ECE BIT(6) 32 + #define ENETC4_TCP_FLAGS_CWR BIT(7) 33 + #define ENETC4_TCP_FLAGS_NS BIT(8) 34 + /* According to tso_build_hdr(), clear all special flags for not last packet. */ 35 + #define ENETC4_TCP_NL_SEG_FLAGS_DMASK (ENETC4_TCP_FLAGS_FIN | \ 36 + ENETC4_TCP_FLAGS_RST | ENETC4_TCP_FLAGS_PSH) 37 + 15 38 /***************************ENETC port registers**************************/ 16 39 #define ENETC4_ECAPR0 0x0 17 40 #define ECAPR0_RFS BIT(2)
+25 -6
drivers/net/ethernet/freescale/enetc/enetc_hw.h
··· 25 25 #define ENETC_SIPCAPR0 0x20 26 26 #define ENETC_SIPCAPR0_RSS BIT(8) 27 27 #define ENETC_SIPCAPR0_RFS BIT(2) 28 + #define ENETC_SIPCAPR0_LSO BIT(1) 28 29 #define ENETC_SIPCAPR1 0x24 29 30 #define ENETC_SITGTGR 0x30 30 31 #define ENETC_SIRBGCR 0x38 ··· 555 554 union enetc_tx_bd { 556 555 struct { 557 556 __le64 addr; 558 - __le16 buf_len; 557 + union { 558 + __le16 buf_len; 559 + __le16 hdr_len; /* For LSO, ENETC 4.1 and later */ 560 + }; 559 561 __le16 frm_len; 560 562 union { 561 563 struct { 562 - u8 reserved[3]; 564 + u8 l3_aux0; 565 + #define ENETC_TX_BD_L3_START GENMASK(6, 0) 566 + #define ENETC_TX_BD_IPCS BIT(7) 567 + u8 l3_aux1; 568 + #define ENETC_TX_BD_L3_HDR_LEN GENMASK(6, 0) 569 + #define ENETC_TX_BD_L3T BIT(7) 570 + u8 l4_aux; 571 + #define ENETC_TX_BD_L4T GENMASK(7, 5) 572 + #define ENETC_TXBD_L4T_UDP 1 573 + #define ENETC_TXBD_L4T_TCP 2 563 574 u8 flags; 564 575 }; /* default layout */ 565 576 __le32 txstart; ··· 582 569 __le32 tstamp; 583 570 __le16 tpid; 584 571 __le16 vid; 585 - u8 reserved[6]; 572 + __le16 lso_sg_size; /* For ENETC 4.1 and later */ 573 + __le16 frm_len_ext; /* For ENETC 4.1 and later */ 574 + u8 reserved[2]; 586 575 u8 e_flags; 587 576 u8 flags; 588 577 } ext; /* Tx BD extension */ 589 578 struct { 590 579 __le32 tstamp; 591 - u8 reserved[10]; 580 + u8 reserved[8]; 581 + __le16 lso_err_count; /* For ENETC 4.1 and later */ 592 582 u8 status; 593 583 u8 flags; 594 584 } wb; /* writeback descriptor */ 595 585 }; 596 586 597 587 enum enetc_txbd_flags { 598 - ENETC_TXBD_FLAGS_RES0 = BIT(0), /* reserved */ 588 + ENETC_TXBD_FLAGS_L4CS = BIT(0), /* For ENETC 4.1 and later */ 599 589 ENETC_TXBD_FLAGS_TSE = BIT(1), 590 + ENETC_TXBD_FLAGS_LSO = BIT(1), /* For ENETC 4.1 and later */ 600 591 ENETC_TXBD_FLAGS_W = BIT(2), 601 - ENETC_TXBD_FLAGS_RES3 = BIT(3), /* reserved */ 592 + ENETC_TXBD_FLAGS_CSUM_LSO = BIT(3), /* For ENETC 4.1 and later */ 602 593 ENETC_TXBD_FLAGS_TXSTART = BIT(4), 603 594 ENETC_TXBD_FLAGS_EX = BIT(6), 604 595 ENETC_TXBD_FLAGS_F = BIT(7) ··· 670 653 671 654 #define ENETC_CBD_FLAGS_SF BIT(7) /* short format */ 672 655 #define ENETC_CBD_STATUS_MASK 0xf 656 + 657 + #define ENETC_TPID_8021Q 0 673 658 674 659 struct enetc_cmd_rfse { 675 660 u8 smac_h[6];
+11 -2
drivers/net/ethernet/freescale/enetc/enetc_pf_common.c
··· 101 101 102 102 priv->msg_enable = (NETIF_MSG_WOL << 1) - 1; 103 103 priv->sysclk_freq = si->drvdata->sysclk_freq; 104 + priv->max_frags = si->drvdata->max_frags; 104 105 ndev->netdev_ops = ndev_ops; 105 106 enetc_set_ethtool_ops(ndev); 106 107 ndev->watchdog_timeo = 5 * HZ; ··· 110 109 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | 111 110 NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX | 112 111 NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_LOOPBACK | 113 - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; 112 + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | 113 + NETIF_F_GSO_UDP_L4; 114 114 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | 115 115 NETIF_F_HW_VLAN_CTAG_TX | 116 116 NETIF_F_HW_VLAN_CTAG_RX | 117 - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; 117 + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | 118 + NETIF_F_GSO_UDP_L4; 118 119 ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | 119 120 NETIF_F_TSO | NETIF_F_TSO6; 120 121 121 122 ndev->priv_flags |= IFF_UNICAST_FLT; 123 + 124 + if (si->drvdata->tx_csum) 125 + priv->active_offloads |= ENETC_F_TXCSUM; 126 + 127 + if (si->hw_features & ENETC_SI_F_LSO) 128 + priv->active_offloads |= ENETC_F_LSO; 122 129 123 130 /* TODO: currently, i.MX95 ENETC driver does not support advanced features */ 124 131 if (!is_enetc_rev1(si)) {
+5 -2
drivers/net/ethernet/freescale/enetc/enetc_vf.c
··· 136 136 137 137 priv->msg_enable = (NETIF_MSG_IFUP << 1) - 1; 138 138 priv->sysclk_freq = si->drvdata->sysclk_freq; 139 + priv->max_frags = si->drvdata->max_frags; 139 140 ndev->netdev_ops = ndev_ops; 140 141 enetc_set_ethtool_ops(ndev); 141 142 ndev->watchdog_timeo = 5 * HZ; ··· 145 144 ndev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | 146 145 NETIF_F_HW_VLAN_CTAG_TX | 147 146 NETIF_F_HW_VLAN_CTAG_RX | 148 - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; 147 + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | 148 + NETIF_F_GSO_UDP_L4; 149 149 ndev->features = NETIF_F_HIGHDMA | NETIF_F_SG | NETIF_F_RXCSUM | 150 150 NETIF_F_HW_VLAN_CTAG_TX | 151 151 NETIF_F_HW_VLAN_CTAG_RX | 152 - NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6; 152 + NETIF_F_HW_CSUM | NETIF_F_TSO | NETIF_F_TSO6 | 153 + NETIF_F_GSO_UDP_L4; 153 154 ndev->vlan_features = NETIF_F_SG | NETIF_F_HW_CSUM | 154 155 NETIF_F_TSO | NETIF_F_TSO6; 155 156