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 'net-fec-general-vlan-cleanups'

Marc Kleine-Budde says:

====================
net: fec: general + VLAN cleanups

This series first cleans up the fec driver a bit (typos, obsolete
comments, add missing header files, rename struct, replace magic
number by defines).

The last 5 patches clean up the fec_enet_rx_queue() function,
including VLAN handling.

v3: https://patch.msgid.link/20250617-fec-cleanups-v3-0-a57bfb38993f@pengutronix.de
v2: https://patch.msgid.link/20250612-fec-cleanups-v2-0-ae7c36df185e@pengutronix.de
v1: https://patch.msgid.link/20241016-fec-cleanups-v1-0-de783bd15e6a@pengutronix.de
====================

Link: https://patch.msgid.link/20250618-fec-cleanups-v4-0-c16f9a1af124@pengutronix.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+96 -100
+7 -8
drivers/net/ethernet/freescale/fec.h
··· 14 14 #define FEC_H 15 15 /****************************************************************************/ 16 16 17 + #include <dt-bindings/firmware/imx/rsrc.h> 18 + #include <linux/bpf.h> 17 19 #include <linux/clocksource.h> 20 + #include <linux/firmware/imx/sci.h> 18 21 #include <linux/net_tstamp.h> 19 22 #include <linux/pm_qos.h> 20 - #include <linux/bpf.h> 21 23 #include <linux/ptp_clock_kernel.h> 22 24 #include <linux/timecounter.h> 23 - #include <dt-bindings/firmware/imx/rsrc.h> 24 - #include <linux/firmware/imx/sci.h> 25 25 #include <net/xdp.h> 26 26 27 27 #if defined(CONFIG_M523x) || defined(CONFIG_M527x) || defined(CONFIG_M528x) || \ ··· 115 115 #define IEEE_T_MCOL 0x254 /* Frames tx'd with multiple collision */ 116 116 #define IEEE_T_DEF 0x258 /* Frames tx'd after deferral delay */ 117 117 #define IEEE_T_LCOL 0x25c /* Frames tx'd with late collision */ 118 - #define IEEE_T_EXCOL 0x260 /* Frames tx'd with excesv collisions */ 118 + #define IEEE_T_EXCOL 0x260 /* Frames tx'd with excessive collisions */ 119 119 #define IEEE_T_MACERR 0x264 /* Frames tx'd with TX FIFO underrun */ 120 120 #define IEEE_T_CSERR 0x268 /* Frames tx'd with carrier sense err */ 121 121 #define IEEE_T_SQE 0x26c /* Frames tx'd with SQE err */ ··· 342 342 #define FEC_TX_BD_FTYPE(X) (((X) & 0xf) << 20) 343 343 344 344 /* The number of Tx and Rx buffers. These are allocated from the page 345 - * pool. The code may assume these are power of two, so it it best 345 + * pool. The code may assume these are power of two, so it is best 346 346 * to keep them that size. 347 347 * We don't need to allocate pages for the transmitter. We just use 348 348 * the skbuffer directly. ··· 460 460 #define FEC_QUIRK_SINGLE_MDIO (1 << 11) 461 461 /* Controller supports RACC register */ 462 462 #define FEC_QUIRK_HAS_RACC (1 << 12) 463 - /* Controller supports interrupt coalesc */ 463 + /* Controller supports interrupt coalesce */ 464 464 #define FEC_QUIRK_HAS_COALESCE (1 << 13) 465 465 /* Interrupt doesn't wake CPU from deep idle */ 466 466 #define FEC_QUIRK_ERR006687 (1 << 14) ··· 495 495 */ 496 496 #define FEC_QUIRK_HAS_EEE (1 << 20) 497 497 498 - /* i.MX8QM ENET IP version add new feture to generate delayed TXC/RXC 498 + /* i.MX8QM ENET IP version add new feature to generate delayed TXC/RXC 499 499 * as an alternative option to make sure it works well with various PHYs. 500 500 * For the implementation of delayed clock, ENET takes synchronized 250MHz 501 501 * clocks to generate 2ns delay. ··· 614 614 unsigned int num_tx_queues; 615 615 unsigned int num_rx_queues; 616 616 617 - /* The saved address of a sent-in-place packet/buffer, for skfree(). */ 618 617 struct fec_enet_priv_tx_q *tx_queue[FEC_ENET_MAX_TX_QS]; 619 618 struct fec_enet_priv_rx_q *rx_queue[FEC_ENET_MAX_RX_QS]; 620 619
+67 -70
drivers/net/ethernet/freescale/fec_main.c
··· 22 22 * Copyright (C) 2010-2011 Freescale Semiconductor, Inc. 23 23 */ 24 24 25 - #include <linux/module.h> 26 - #include <linux/kernel.h> 27 - #include <linux/string.h> 28 - #include <linux/pm_runtime.h> 29 - #include <linux/ptrace.h> 30 - #include <linux/errno.h> 31 - #include <linux/ioport.h> 32 - #include <linux/slab.h> 33 - #include <linux/interrupt.h> 25 + #include <linux/bitops.h> 26 + #include <linux/bpf.h> 27 + #include <linux/bpf_trace.h> 28 + #include <linux/cacheflush.h> 29 + #include <linux/clk.h> 30 + #include <linux/crc32.h> 34 31 #include <linux/delay.h> 35 - #include <linux/netdevice.h> 32 + #include <linux/errno.h> 36 33 #include <linux/etherdevice.h> 37 - #include <linux/skbuff.h> 34 + #include <linux/fec.h> 35 + #include <linux/filter.h> 36 + #include <linux/gpio/consumer.h> 37 + #include <linux/icmp.h> 38 + #include <linux/if_vlan.h> 38 39 #include <linux/in.h> 40 + #include <linux/interrupt.h> 41 + #include <linux/io.h> 42 + #include <linux/ioport.h> 39 43 #include <linux/ip.h> 44 + #include <linux/irq.h> 45 + #include <linux/kernel.h> 46 + #include <linux/mdio.h> 47 + #include <linux/mfd/syscon.h> 48 + #include <linux/module.h> 49 + #include <linux/netdevice.h> 50 + #include <linux/of.h> 51 + #include <linux/of_mdio.h> 52 + #include <linux/of_net.h> 53 + #include <linux/phy.h> 54 + #include <linux/pinctrl/consumer.h> 55 + #include <linux/platform_device.h> 56 + #include <linux/pm_runtime.h> 57 + #include <linux/prefetch.h> 58 + #include <linux/property.h> 59 + #include <linux/ptrace.h> 60 + #include <linux/regmap.h> 61 + #include <linux/regulator/consumer.h> 62 + #include <linux/skbuff.h> 63 + #include <linux/slab.h> 64 + #include <linux/spinlock.h> 65 + #include <linux/string.h> 66 + #include <linux/tcp.h> 67 + #include <linux/udp.h> 68 + #include <linux/workqueue.h> 40 69 #include <net/ip.h> 41 70 #include <net/page_pool/helpers.h> 42 71 #include <net/selftests.h> 43 72 #include <net/tso.h> 44 - #include <linux/tcp.h> 45 - #include <linux/udp.h> 46 - #include <linux/icmp.h> 47 - #include <linux/spinlock.h> 48 - #include <linux/workqueue.h> 49 - #include <linux/bitops.h> 50 - #include <linux/io.h> 51 - #include <linux/irq.h> 52 - #include <linux/clk.h> 53 - #include <linux/crc32.h> 54 - #include <linux/platform_device.h> 55 - #include <linux/property.h> 56 - #include <linux/mdio.h> 57 - #include <linux/phy.h> 58 - #include <linux/fec.h> 59 - #include <linux/of.h> 60 - #include <linux/of_mdio.h> 61 - #include <linux/of_net.h> 62 - #include <linux/regulator/consumer.h> 63 - #include <linux/if_vlan.h> 64 - #include <linux/pinctrl/consumer.h> 65 - #include <linux/gpio/consumer.h> 66 - #include <linux/prefetch.h> 67 - #include <linux/mfd/syscon.h> 68 - #include <linux/regmap.h> 69 73 #include <soc/imx/cpuidle.h> 70 - #include <linux/filter.h> 71 - #include <linux/bpf.h> 72 - #include <linux/bpf_trace.h> 73 - 74 - #include <asm/cacheflush.h> 75 74 76 75 #include "fec.h" 77 76 ··· 130 131 FEC_QUIRK_HAS_MDIO_C45, 131 132 }; 132 133 133 - static const struct fec_devinfo fec_imx6x_info = { 134 + static const struct fec_devinfo fec_imx6sx_info = { 134 135 .quirks = FEC_QUIRK_ENET_MAC | FEC_QUIRK_HAS_GBIT | 135 136 FEC_QUIRK_HAS_BUFDESC_EX | FEC_QUIRK_HAS_CSUM | 136 137 FEC_QUIRK_HAS_VLAN | FEC_QUIRK_HAS_AVB | ··· 195 196 { .compatible = "fsl,imx28-fec", .data = &fec_imx28_info, }, 196 197 { .compatible = "fsl,imx6q-fec", .data = &fec_imx6q_info, }, 197 198 { .compatible = "fsl,mvf600-fec", .data = &fec_mvf600_info, }, 198 - { .compatible = "fsl,imx6sx-fec", .data = &fec_imx6x_info, }, 199 + { .compatible = "fsl,imx6sx-fec", .data = &fec_imx6sx_info, }, 199 200 { .compatible = "fsl,imx6ul-fec", .data = &fec_imx6ul_info, }, 200 201 { .compatible = "fsl,imx8mq-fec", .data = &fec_imx8mq_info, }, 201 202 { .compatible = "fsl,imx8qm-fec", .data = &fec_imx8qm_info, }, ··· 275 276 #define FEC_ECR_MAGICEN BIT(2) 276 277 #define FEC_ECR_SLEEP BIT(3) 277 278 #define FEC_ECR_EN1588 BIT(4) 279 + #define FEC_ECR_SPEED BIT(5) 278 280 #define FEC_ECR_BYTESWP BIT(8) 279 281 /* FEC RCR bits definition */ 280 282 #define FEC_RCR_LOOP BIT(0) ··· 1207 1207 /* 1G, 100M or 10M */ 1208 1208 if (ndev->phydev) { 1209 1209 if (ndev->phydev->speed == SPEED_1000) 1210 - ecntl |= (1 << 5); 1210 + ecntl |= FEC_ECR_SPEED; 1211 1211 else if (ndev->phydev->speed == SPEED_100) 1212 1212 rcntl &= ~FEC_RCR_10BASET; 1213 1213 else ··· 1706 1706 return ret; 1707 1707 } 1708 1708 1709 + static void fec_enet_rx_vlan(const struct net_device *ndev, struct sk_buff *skb) 1710 + { 1711 + if (ndev->features & NETIF_F_HW_VLAN_CTAG_RX) { 1712 + const struct vlan_ethhdr *vlan_header = skb_vlan_eth_hdr(skb); 1713 + const u16 vlan_tag = ntohs(vlan_header->h_vlan_TCI); 1714 + 1715 + /* Push and remove the vlan tag */ 1716 + 1717 + memmove(skb->data + VLAN_HLEN, skb->data, ETH_ALEN * 2); 1718 + skb_pull(skb, VLAN_HLEN); 1719 + __vlan_hwaccel_put_tag(skb, 1720 + htons(ETH_P_8021Q), 1721 + vlan_tag); 1722 + } 1723 + } 1724 + 1709 1725 /* During a receive, the bd_rx.cur points to the current incoming buffer. 1710 1726 * When we update through the ring, if the next incoming buffer has 1711 1727 * not been given to the system, we just set the empty indicator, 1712 1728 * effectively tossing the packet. 1713 1729 */ 1714 1730 static int 1715 - fec_enet_rx_queue(struct net_device *ndev, int budget, u16 queue_id) 1731 + fec_enet_rx_queue(struct net_device *ndev, u16 queue_id, int budget) 1716 1732 { 1717 1733 struct fec_enet_private *fep = netdev_priv(ndev); 1718 1734 struct fec_enet_priv_rx_q *rxq; ··· 1736 1720 unsigned short status; 1737 1721 struct sk_buff *skb; 1738 1722 ushort pkt_len; 1739 - __u8 *data; 1740 1723 int pkt_received = 0; 1741 1724 struct bufdesc_ex *ebdp = NULL; 1742 - bool vlan_packet_rcvd = false; 1743 - u16 vlan_tag; 1744 1725 int index = 0; 1745 1726 bool need_swap = fep->quirks & FEC_QUIRK_SWAP_FRAME; 1746 1727 struct bpf_prog *xdp_prog = READ_ONCE(fep->xdp_prog); ··· 1856 1843 skb_mark_for_recycle(skb); 1857 1844 1858 1845 if (unlikely(need_swap)) { 1846 + u8 *data; 1847 + 1859 1848 data = page_address(page) + FEC_ENET_XDP_HEADROOM; 1860 1849 swap_buffer(data, pkt_len); 1861 1850 } 1862 - data = skb->data; 1863 1851 1864 1852 /* Extract the enhanced buffer descriptor */ 1865 1853 ebdp = NULL; ··· 1868 1854 ebdp = (struct bufdesc_ex *)bdp; 1869 1855 1870 1856 /* If this is a VLAN packet remove the VLAN Tag */ 1871 - vlan_packet_rcvd = false; 1872 - if ((ndev->features & NETIF_F_HW_VLAN_CTAG_RX) && 1873 - fep->bufdesc_ex && 1874 - (ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) { 1875 - /* Push and remove the vlan tag */ 1876 - struct vlan_hdr *vlan_header = 1877 - (struct vlan_hdr *) (data + ETH_HLEN); 1878 - vlan_tag = ntohs(vlan_header->h_vlan_TCI); 1879 - 1880 - vlan_packet_rcvd = true; 1881 - 1882 - memmove(skb->data + VLAN_HLEN, data, ETH_ALEN * 2); 1883 - skb_pull(skb, VLAN_HLEN); 1884 - } 1857 + if (fep->bufdesc_ex && 1858 + (ebdp->cbd_esc & cpu_to_fec32(BD_ENET_RX_VLAN))) 1859 + fec_enet_rx_vlan(ndev, skb); 1885 1860 1886 1861 skb->protocol = eth_type_trans(skb, ndev); 1887 1862 ··· 1888 1885 skb_checksum_none_assert(skb); 1889 1886 } 1890 1887 } 1891 - 1892 - /* Handle received VLAN packets */ 1893 - if (vlan_packet_rcvd) 1894 - __vlan_hwaccel_put_tag(skb, 1895 - htons(ETH_P_8021Q), 1896 - vlan_tag); 1897 1888 1898 1889 skb_record_rx_queue(skb, queue_id); 1899 1890 napi_gro_receive(&fep->napi, skb); ··· 1936 1939 1937 1940 /* Make sure that AVB queues are processed first. */ 1938 1941 for (i = fep->num_rx_queues - 1; i >= 0; i--) 1939 - done += fec_enet_rx_queue(ndev, budget - done, i); 1942 + done += fec_enet_rx_queue(ndev, i, budget - done); 1940 1943 1941 1944 return done; 1942 1945 }
+1 -1
drivers/net/ethernet/freescale/fec_mpc52xx.c
··· 619 619 out_be32(&fec->rfifo_alarm, 0x0000030c); 620 620 out_be32(&fec->tfifo_alarm, 0x00000100); 621 621 622 - /* begin transmittion when 256 bytes are in FIFO (or EOF or FIFO full) */ 622 + /* begin transmission when 256 bytes are in FIFO (or EOF or FIFO full) */ 623 623 out_be32(&fec->x_wmrk, FEC_FIFO_WMRK_256B); 624 624 625 625 /* enable crc generation */
+21 -21
drivers/net/ethernet/freescale/fec_ptp.c
··· 7 7 8 8 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 9 9 10 - #include <linux/module.h> 11 - #include <linux/kernel.h> 12 - #include <linux/string.h> 13 - #include <linux/ptrace.h> 14 - #include <linux/errno.h> 15 - #include <linux/ioport.h> 16 - #include <linux/slab.h> 17 - #include <linux/interrupt.h> 18 - #include <linux/pci.h> 19 - #include <linux/delay.h> 20 - #include <linux/netdevice.h> 21 - #include <linux/etherdevice.h> 22 - #include <linux/skbuff.h> 23 - #include <linux/spinlock.h> 24 - #include <linux/workqueue.h> 25 10 #include <linux/bitops.h> 26 - #include <linux/io.h> 27 - #include <linux/irq.h> 28 11 #include <linux/clk.h> 29 - #include <linux/platform_device.h> 30 - #include <linux/phy.h> 12 + #include <linux/delay.h> 13 + #include <linux/errno.h> 14 + #include <linux/etherdevice.h> 31 15 #include <linux/fec.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/io.h> 18 + #include <linux/ioport.h> 19 + #include <linux/irq.h> 20 + #include <linux/kernel.h> 21 + #include <linux/module.h> 22 + #include <linux/netdevice.h> 32 23 #include <linux/of.h> 33 24 #include <linux/of_net.h> 25 + #include <linux/pci.h> 26 + #include <linux/phy.h> 27 + #include <linux/platform_device.h> 28 + #include <linux/ptrace.h> 29 + #include <linux/skbuff.h> 30 + #include <linux/slab.h> 31 + #include <linux/spinlock.h> 32 + #include <linux/string.h> 33 + #include <linux/workqueue.h> 34 34 35 35 #include "fec.h" 36 36 ··· 117 117 * @fep: the fec_enet_private structure handle 118 118 * @enable: enable the channel pps output 119 119 * 120 - * This function enble the PPS ouput on the timer channel. 120 + * This function enables the PPS output on the timer channel. 121 121 */ 122 122 static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable) 123 123 { ··· 172 172 * very close to the second point, which means NSEC_PER_SEC 173 173 * - ts.tv_nsec is close to be zero(For example 20ns); Since the timer 174 174 * is still running when we calculate the first compare event, it is 175 - * possible that the remaining nanoseonds run out before the compare 175 + * possible that the remaining nanoseconds run out before the compare 176 176 * counter is calculated and written into TCCR register. To avoid 177 177 * this possibility, we will set the compare event to be the next 178 178 * of next second. The current setting is 31-bit timer and wrap