rocker: add change MTU support
Subsystems (3)
PATCH 1/1 rocker: add change MTU support
From: Scott Feldman <[email protected]>
Implement ndo_change_mtu: on MTU change, reallocate Rx ring bufs and signal HW of new port MTU value.
Signed-off-by Scott Feldman <[email protected]>
--- drivers/net/ethernet/rocker/rocker.c | 61 ++++++++++++++++++++++++++++++++++ drivers/net/ethernet/rocker/rocker.h | 1 + 2 files changed, 62 insertions(+)
drivers/net/ethernet/rocker/rocker.c +61 -0
@@ -1818,6 +1818,30 @@ rocker_cmd_set_port_settings_macaddr_prep(const struct rocker_port *rocker_port, }static int +rocker_cmd_set_port_settings_mtu_prep (const struct rocker_port *rocker_port, +struct rocker_desc_info *desc_info, +void *priv) +{ +int mtu = *(int *)priv; +struct rocker_tlv *cmd_info; + +if (rocker_tlv_put_u16 (desc_info,ROCKER_TLV_CMD_TYPE , +ROCKER_TLV_CMD_TYPE_SET_PORT_SETTINGS )) +return -EMSGSIZE ; + cmd_info =rocker_tlv_nest_start (desc_info,ROCKER_TLV_CMD_INFO ); +if (!cmd_info) +return -EMSGSIZE ; +if (rocker_tlv_put_u32 (desc_info,ROCKER_TLV_CMD_PORT_SETTINGS_PPORT , + rocker_port->pport)) +return -EMSGSIZE ; +if (rocker_tlv_put_u16 (desc_info,ROCKER_TLV_CMD_PORT_SETTINGS_MTU , + mtu)) +return -EMSGSIZE ; +rocker_tlv_nest_end (desc_info, cmd_info); +return 0 ; +} + +static int rocker_cmd_set_port_learning_prep (const struct rocker_port *rocker_port,struct rocker_desc_info *desc_info,void *priv)
@@ -1874,6 +1898,14 @@ static int rocker_cmd_set_port_settings_macaddr(struct rocker_port *rocker_port, macaddr, NULL, NULL); } +static int rocker_cmd_set_port_settings_mtu (struct rocker_port *rocker_port, +int mtu) +{ +return rocker_cmd_exec (rocker_port,SWITCHDEV_TRANS_NONE ,0 , + rocker_cmd_set_port_settings_mtu_prep, + &mtu,NULL ,NULL ); +} +static int rocker_port_set_learning (struct rocker_port *rocker_port,enum switchdev_trans trans) {
@@ -4152,6 +4184,34 @@ static int rocker_port_set_mac_address(struct net_device *dev, void *p)return 0 ; } +static int rocker_port_change_mtu (struct net_device *dev,int new_mtu) +{ +struct rocker_port *rocker_port =netdev_priv (dev); +int running =netif_running (dev); +int err; + +#define ROCKER_PORT_MIN_MTU 68 +#define ROCKER_PORT_MAX_MTU 9000 + +if (new_mtu <ROCKER_PORT_MIN_MTU || new_mtu >ROCKER_PORT_MAX_MTU ) +return -EINVAL ; + +if (running) +rocker_port_stop (dev); + +netdev_info (dev,"MTU change from %d to %d\n" , dev->mtu, new_mtu); + dev->mtu = new_mtu; + + err =rocker_cmd_set_port_settings_mtu (rocker_port, new_mtu); +if (err) +return err; + +if (running) + err =rocker_port_open (dev); + +return err; +} +static int rocker_port_get_phys_port_name (struct net_device *dev,char *buf,size_t len) {
@@ -4172,6 +4232,7 @@ static const struct net_device_ops rocker_port_netdev_ops = { .ndo_stop = rocker_port_stop, .ndo_start_xmit = rocker_port_xmit, .ndo_set_mac_address = rocker_port_set_mac_address, + .ndo_change_mtu = rocker_port_change_mtu, .ndo_bridge_getlink = switchdev_port_bridge_getlink, .ndo_bridge_setlink = switchdev_port_bridge_setlink, .ndo_bridge_dellink = switchdev_port_bridge_dellink,
drivers/net/ethernet/rocker/rocker.h +1 -0
@@ -159,6 +159,7 @@ enum {ROCKER_TLV_CMD_PORT_SETTINGS_MODE ,/* u8 */ ROCKER_TLV_CMD_PORT_SETTINGS_LEARNING ,/* u8 */ ROCKER_TLV_CMD_PORT_SETTINGS_PHYS_NAME ,/* binary */ +ROCKER_TLV_CMD_PORT_SETTINGS_MTU ,/* u16 */ __ROCKER_TLV_CMD_PORT_SETTINGS_MAX, ROCKER_TLV_CMD_PORT_SETTINGS_MAX =
Signature · 1 line
1.7.10.4
Quoted 6 lines · On Wed, Jul 08, 2015 at 04:06:47PM -0700, [email protected] wrote:
From: Scott Feldman <[email protected]>
Implement
ndo_change_mtu: on MTU change, reallocate Rx ring bufs and signal HW of new port MTU value.Signed-off-by Scott Feldman <[email protected]>
Looks good :)
Reviewed-by Simon Horman <[email protected]>
Tested-by Simon Horman <[email protected]>
Quoted 6 lines · Thu, Jul 09, 2015 at 01:06:47AM CEST, [email protected] wrote:
From: Scott Feldman <[email protected]>
Implement
ndo_change_mtu: on MTU change, reallocate Rx ring bufs and signal HW of new port MTU value.Signed-off-by Scott Feldman <[email protected]>
Acked-by Jiri Pirko <[email protected]>
From: [email protected]
Date: Wed, 8 Jul 2015 16:06:47 -0700
Quoted 6 lines
From: Scott Feldman <[email protected]>
Implement
ndo_change_mtu: on MTU change, reallocate Rx ring bufs and signal HW of new port MTU value.Signed-off-by Scott Feldman <[email protected]>
Applied, thanks Scott.