1 From cf3e71b3c8bd63cd832c0512386700cac6a2c363 Mon Sep 17 00:00:00 2001
2 From: Luo Jie <quic_luoj@quicinc.com>
3 Date: Tue, 5 Mar 2024 16:42:56 +0800
4 Subject: [PATCH 35/50] net: ethernet: qualcomm: Add API to configure PPE port
7 This function is called when the MTU of an ethernet port is
8 configured. It limits the size of packet passed through the
11 Change-Id: I2a4dcd04407156d73770d2becbb7cbc0d56b3754
12 Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
14 drivers/net/ethernet/qualcomm/ppe/ppe_port.c | 44 ++++++++++++++++++++
15 drivers/net/ethernet/qualcomm/ppe/ppe_port.h | 1 +
16 2 files changed, 45 insertions(+)
18 --- a/drivers/net/ethernet/qualcomm/ppe/ppe_port.c
19 +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_port.c
20 @@ -537,6 +537,50 @@ int ppe_port_set_mac_eee(struct ppe_port
25 + * ppe_port_set_maxframe() - Set port maximum frame size
26 + * @ppe_port: PPE port structure
27 + * @maxframe_size: Maximum frame size supported by PPE port
29 + * Description: Set MTU of network interface specified by @ppe_port.
31 + * Return: 0 upon success or a negative error upon failure.
33 +int ppe_port_set_maxframe(struct ppe_port *ppe_port, int maxframe_size)
35 + struct ppe_device *ppe_dev = ppe_port->ppe_dev;
36 + u32 reg, val, mru_mtu_val[3];
37 + int port = ppe_port->port_id;
40 + /* The max frame size should be MTU added by ETH_HLEN in PPE. */
41 + maxframe_size += ETH_HLEN;
43 + /* MAC takes cover the FCS for the calculation of frame size. */
44 + if (maxframe_size > PPE_PORT_MAC_MAX_FRAME_SIZE - ETH_FCS_LEN)
47 + reg = PPE_MC_MTU_CTRL_TBL_ADDR + PPE_MC_MTU_CTRL_TBL_INC * port;
48 + val = FIELD_PREP(PPE_MC_MTU_CTRL_TBL_MTU, maxframe_size);
49 + ret = regmap_update_bits(ppe_dev->regmap, reg,
50 + PPE_MC_MTU_CTRL_TBL_MTU,
55 + reg = PPE_MRU_MTU_CTRL_TBL_ADDR + PPE_MRU_MTU_CTRL_TBL_INC * port;
56 + ret = regmap_bulk_read(ppe_dev->regmap, reg,
57 + mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
61 + PPE_MRU_MTU_CTRL_SET_MRU(mru_mtu_val, maxframe_size);
62 + PPE_MRU_MTU_CTRL_SET_MTU(mru_mtu_val, maxframe_size);
64 + return regmap_bulk_write(ppe_dev->regmap, reg,
65 + mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
68 /* PPE port and MAC reset */
69 static int ppe_port_mac_reset(struct ppe_port *ppe_port)
71 --- a/drivers/net/ethernet/qualcomm/ppe/ppe_port.h
72 +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_port.h
73 @@ -89,4 +89,5 @@ void ppe_port_get_stats64(struct ppe_por
74 struct rtnl_link_stats64 *s);
75 int ppe_port_set_mac_address(struct ppe_port *ppe_port, const u8 *addr);
76 int ppe_port_set_mac_eee(struct ppe_port *ppe_port, struct ethtool_eee *eee);
77 +int ppe_port_set_maxframe(struct ppe_port *ppe_port, int maxframe_size);