]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mlxsw: spectrum: Track MTU in struct mlxsw_sp_hdroom
authorPetr Machata <petrm@nvidia.com>
Wed, 16 Sep 2020 06:35:16 +0000 (09:35 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Sep 2020 22:19:29 +0000 (15:19 -0700)
MTU influences sizes of auto-allocated buffers. Make it a part of port
buffer configuration and have __mlxsw_sp_port_headroom_set() take it from
there, instead of as an argument.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_dcb.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_ethtool.c

index e436640abd4e06367c070355f0f2615c7fb2bc33..f3f8c025cc2d2352542f6fd873d700682a0eb04d 100644 (file)
@@ -627,7 +627,7 @@ static void mlxsw_sp_pg_buf_pack(char *pbmc_pl, int index, u16 size, u16 thres,
 }
 
 static u16 mlxsw_sp_hdroom_buf_delay_get(const struct mlxsw_sp *mlxsw_sp,
-                                        const struct mlxsw_sp_hdroom *hdroom, int mtu)
+                                        const struct mlxsw_sp_hdroom *hdroom)
 {
        u16 delay_cells;
 
@@ -641,12 +641,12 @@ static u16 mlxsw_sp_hdroom_buf_delay_get(const struct mlxsw_sp *mlxsw_sp,
         * Another MTU is added in case the transmitting host already started
         * transmitting a maximum length frame when the PFC packet was received.
         */
-       return 2 * delay_cells + mlxsw_sp_bytes_cells(mlxsw_sp, mtu);
+       return 2 * delay_cells + mlxsw_sp_bytes_cells(mlxsw_sp, hdroom->mtu);
 }
 
 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                 struct mlxsw_sp_hdroom *hdroom,
-                                int mtu, u8 *prio_tc, bool pause_en, struct ieee_pfc *my_pfc)
+                                u8 *prio_tc, bool pause_en, struct ieee_pfc *my_pfc)
 {
        struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
        u8 pfc_en = !!my_pfc ? my_pfc->pfc_en : 0;
@@ -682,9 +682,9 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
                        continue;
 
                lossy = !(pfc || pause_en);
-               thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, mtu);
+               thres_cells = mlxsw_sp_pg_buf_threshold_get(mlxsw_sp, hdroom->mtu);
                thres_cells = mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, thres_cells);
-               delay_cells = mlxsw_sp_hdroom_buf_delay_get(mlxsw_sp, hdroom, mtu);
+               delay_cells = mlxsw_sp_hdroom_buf_delay_get(mlxsw_sp, hdroom);
                delay_cells = mlxsw_sp_port_headroom_8x_adjust(mlxsw_sp_port, delay_cells);
                total_cells = thres_cells + delay_cells;
 
@@ -706,7 +706,7 @@ int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
 
 int mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
                               struct mlxsw_sp_hdroom *hdroom,
-                              int mtu, bool pause_en)
+                              bool pause_en)
 {
        u8 def_prio_tc[IEEE_8021QAZ_MAX_TCS] = {0};
        bool dcb_en = !!mlxsw_sp_port->dcb.ets;
@@ -716,19 +716,25 @@ int mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
        prio_tc = dcb_en ? mlxsw_sp_port->dcb.ets->prio_tc : def_prio_tc;
        my_pfc = dcb_en ? mlxsw_sp_port->dcb.pfc : NULL;
 
-       return __mlxsw_sp_port_headroom_set(mlxsw_sp_port, hdroom, mtu, prio_tc,
-                                           pause_en, my_pfc);
+       return __mlxsw_sp_port_headroom_set(mlxsw_sp_port, hdroom, prio_tc, pause_en, my_pfc);
 }
 
 static int mlxsw_sp_port_change_mtu(struct net_device *dev, int mtu)
 {
        struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
        bool pause_en = mlxsw_sp_port_is_pause_en(mlxsw_sp_port);
+       struct mlxsw_sp_hdroom orig_hdroom;
+       struct mlxsw_sp_hdroom hdroom;
        int err;
 
-       err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, mlxsw_sp_port->hdroom, mtu, pause_en);
+       orig_hdroom = *mlxsw_sp_port->hdroom;
+
+       hdroom = orig_hdroom;
+       hdroom.mtu = mtu;
+       err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, &hdroom, pause_en);
        if (err)
                return err;
+
        err = mlxsw_sp_port_mtu_set(mlxsw_sp_port, mtu);
        if (err)
                goto err_port_mtu_set;
@@ -736,7 +742,7 @@ static int mlxsw_sp_port_change_mtu(struct net_device *dev, int mtu)
        return 0;
 
 err_port_mtu_set:
-       mlxsw_sp_port_headroom_set(mlxsw_sp_port, mlxsw_sp_port->hdroom, dev->mtu, pause_en);
+       mlxsw_sp_port_headroom_set(mlxsw_sp_port, &orig_hdroom, pause_en);
        return err;
 }
 
index 6d69f191a3fe00709193ea589ca872c9343c885e..e2ac258ea9c72946a76542bd99591f885437d9c9 100644 (file)
@@ -432,7 +432,7 @@ enum mlxsw_sp_flood_type {
 
 int mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
                               struct mlxsw_sp_hdroom *hdroom,
-                              int mtu, bool pause_en);
+                              bool pause_en);
 int mlxsw_sp_port_get_stats_raw(struct net_device *dev, int grp,
                                int prio, char *ppcnt_pl);
 int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
@@ -441,6 +441,7 @@ int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
 /* spectrum_buffers.c */
 struct mlxsw_sp_hdroom {
        int delay_bytes;
+       int mtu;
 };
 
 int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
@@ -526,7 +527,7 @@ int mlxsw_sp_port_prio_tc_set(struct mlxsw_sp_port *mlxsw_sp_port,
                              u8 switch_prio, u8 tclass);
 int __mlxsw_sp_port_headroom_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                 struct mlxsw_sp_hdroom *hdroom,
-                                int mtu, u8 *prio_tc, bool pause_en, struct ieee_pfc *my_pfc);
+                                u8 *prio_tc, bool pause_en, struct ieee_pfc *my_pfc);
 int mlxsw_sp_port_ets_maxrate_set(struct mlxsw_sp_port *mlxsw_sp_port,
                                  enum mlxsw_reg_qeec_hr hr, u8 index,
                                  u8 next_index, u32 maxrate, u8 burst_size);
index 54218e6914083759eacce3f6c8143d3e3eb5c61f..d7a2c4981bcb173c3843da1f2fad1c979ac2c5d8 100644 (file)
@@ -998,6 +998,7 @@ int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port)
        mlxsw_sp_port->hdroom = kzalloc(sizeof(*mlxsw_sp_port->hdroom), GFP_KERNEL);
        if (!mlxsw_sp_port->hdroom)
                return -ENOMEM;
+       mlxsw_sp_port->hdroom->mtu = mlxsw_sp_port->dev->mtu;
 
        err = mlxsw_sp_port_headroom_init(mlxsw_sp_port);
        if (err)
index 65fcd043d96e14320966d380c8ccbb9176f45535..ccb86bc7ae26a06ae3fef0f6873c711e949902ca 100644 (file)
@@ -121,7 +121,7 @@ static int mlxsw_sp_port_headroom_ets_set(struct mlxsw_sp_port *mlxsw_sp_port,
        /* Create the required PGs, but don't destroy existing ones, as
         * traffic is still directed to them.
         */
-       err = __mlxsw_sp_port_headroom_set(mlxsw_sp_port, mlxsw_sp_port->hdroom, dev->mtu,
+       err = __mlxsw_sp_port_headroom_set(mlxsw_sp_port, mlxsw_sp_port->hdroom,
                                           ets->prio_tc, pause_en,
                                           mlxsw_sp_port->dcb.pfc);
        if (err) {
@@ -622,8 +622,7 @@ static int mlxsw_sp_dcbnl_ieee_setpfc(struct net_device *dev,
        else
                hdroom.delay_bytes = 0;
 
-       err = __mlxsw_sp_port_headroom_set(mlxsw_sp_port, &hdroom, dev->mtu,
-                                          mlxsw_sp_port->dcb.ets->prio_tc,
+       err = __mlxsw_sp_port_headroom_set(mlxsw_sp_port, &hdroom, mlxsw_sp_port->dcb.ets->prio_tc,
                                           pause_en, pfc);
        if (err) {
                netdev_err(dev, "Failed to configure port's headroom for PFC\n");
@@ -642,9 +641,8 @@ static int mlxsw_sp_dcbnl_ieee_setpfc(struct net_device *dev,
        return 0;
 
 err_port_pfc_set:
-       __mlxsw_sp_port_headroom_set(mlxsw_sp_port, &orig_hdroom, dev->mtu,
-                                    mlxsw_sp_port->dcb.ets->prio_tc, pause_en,
-                                    mlxsw_sp_port->dcb.pfc);
+       __mlxsw_sp_port_headroom_set(mlxsw_sp_port, &orig_hdroom, mlxsw_sp_port->dcb.ets->prio_tc,
+                                    pause_en, mlxsw_sp_port->dcb.pfc);
        return err;
 }
 
index 8048a8b82d02f00eb1ab2f1279ea96b162e01317..36c02c66bb14c5790b21364c89601730d6b3eb8a 100644 (file)
@@ -224,7 +224,7 @@ static int mlxsw_sp_port_set_pauseparam(struct net_device *dev,
        else
                hdroom.delay_bytes = 0;
 
-       err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, &hdroom, dev->mtu, pause_en);
+       err = mlxsw_sp_port_headroom_set(mlxsw_sp_port, &hdroom, pause_en);
        if (err) {
                netdev_err(dev, "Failed to configure port's headroom\n");
                return err;
@@ -243,7 +243,7 @@ static int mlxsw_sp_port_set_pauseparam(struct net_device *dev,
 
 err_port_pause_configure:
        pause_en = mlxsw_sp_port_is_pause_en(mlxsw_sp_port);
-       mlxsw_sp_port_headroom_set(mlxsw_sp_port, &orig_hdroom, dev->mtu, pause_en);
+       mlxsw_sp_port_headroom_set(mlxsw_sp_port, &orig_hdroom, pause_en);
        return err;
 }