f35ea677b65831175ee8a24e873a1749e5159c41
[openwrt/staging/wigyori.git] / target / linux / layerscape / patches-5.4 / 701-net-0301-staging-fsl_ppfe-eth-define-pfe-ndo_change_mtu-funct.patch
1 From d9c44cf1a757823fb069dea0c15a830513175bf3 Mon Sep 17 00:00:00 2001
2 From: Calvin Johnson <calvin.johnson@nxp.com>
3 Date: Wed, 20 Jun 2018 10:23:01 +0530
4 Subject: [PATCH] staging: fsl_ppfe/eth: define pfe ndo_change_mtu function
5
6 Define ndo_change_mtu function for pfe. This sets the max Rx frame
7 length to the new mtu.
8
9 Signed-off-by: Calvin Johnson <calvin.johnson@nxp.com>
10 ---
11 drivers/staging/fsl_ppfe/include/pfe/pfe.h | 1 +
12 drivers/staging/fsl_ppfe/pfe_eth.c | 12 ++++++++++++
13 drivers/staging/fsl_ppfe/pfe_hal.c | 11 +++++++++++
14 3 files changed, 24 insertions(+)
15
16 --- a/drivers/staging/fsl_ppfe/include/pfe/pfe.h
17 +++ b/drivers/staging/fsl_ppfe/include/pfe/pfe.h
18 @@ -303,6 +303,7 @@ void gemac_allow_broadcast(void *base);
19 void gemac_no_broadcast(void *base);
20 void gemac_enable_1536_rx(void *base);
21 void gemac_disable_1536_rx(void *base);
22 +void gemac_set_rx_max_fl(void *base, int mtu);
23 void gemac_enable_rx_jmb(void *base);
24 void gemac_disable_rx_jmb(void *base);
25 void gemac_enable_stacked_vlan(void *base);
26 --- a/drivers/staging/fsl_ppfe/pfe_eth.c
27 +++ b/drivers/staging/fsl_ppfe/pfe_eth.c
28 @@ -1345,6 +1345,17 @@ static int pfe_eth_event_handler(void *d
29 return 0;
30 }
31
32 +static int pfe_eth_change_mtu(struct net_device *ndev, int new_mtu)
33 +{
34 + struct pfe_eth_priv_s *priv = netdev_priv(ndev);
35 +
36 + ndev->mtu = new_mtu;
37 + new_mtu += ETH_HLEN + ETH_FCS_LEN;
38 + gemac_set_rx_max_fl(priv->EMAC_baseaddr, new_mtu);
39 +
40 + return 0;
41 +}
42 +
43 /* pfe_eth_open
44 */
45 static int pfe_eth_open(struct net_device *ndev)
46 @@ -2246,6 +2257,7 @@ static const struct net_device_ops pfe_n
47 .ndo_set_rx_mode = pfe_eth_set_multi,
48 .ndo_set_mac_address = pfe_eth_set_mac_address,
49 .ndo_validate_addr = eth_validate_addr,
50 + .ndo_change_mtu = pfe_eth_change_mtu,
51 .ndo_get_stats = pfe_eth_get_stats,
52 .ndo_set_features = pfe_eth_set_features,
53 };
54 --- a/drivers/staging/fsl_ppfe/pfe_hal.c
55 +++ b/drivers/staging/fsl_ppfe/pfe_hal.c
56 @@ -1017,6 +1017,17 @@ void gemac_enable_1536_rx(void *base)
57 | (1536 << 16), base + EMAC_RCNTRL_REG);
58 }
59
60 +/* GEMAC set rx Max frame length.
61 + * @param[in] base GEMAC base address
62 + * @param[in] mtu new mtu
63 + */
64 +void gemac_set_rx_max_fl(void *base, int mtu)
65 +{
66 + /* Set mtu as Maximum frame length */
67 + writel((readl(base + EMAC_RCNTRL_REG) & PFE_RCR_MAX_FL_MASK)
68 + | (mtu << 16), base + EMAC_RCNTRL_REG);
69 +}
70 +
71 /* GEMAC enable jumbo function.
72 * @param[in] base GEMAC base address
73 */