KSZ9477, KSZ9567, KSZ9563, KSZ8563 and LAN937x supports Credit based shaper. To differentiate the chip supporting cbs, tc_cbs_supported flag is introduced in ksz_chip_data. And KSZ series has 16bit Credit increment registers whereas LAN937x has 24bit register. The value to be programmed in the credit increment is determined using the successive multiplication method to convert decimal fraction to hexadecimal fraction. For example: if idleslope is 10000 and sendslope is -90000, then bandwidth is 10000 - (-90000) = 100000. The 10% bandwidth of 100Mbps means 10/100 = 0.1(decimal). This value has to be converted to hexa. 1) 0.1 * 16 = 1.6 --> fraction 0.6 Carry = 1 (MSB) 2) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 3) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 4) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 5) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 6) 0.6 * 16 = 9.6 --> fraction 0.6 Carry = 9 (LSB) Now 0.1(decimal) becomes 0.199999(Hex). If it is LAN937x, 24 bit value will be programmed to Credit Inc register, 0x199999. For others 16 bit value will be prgrammed, 0x1999. Signed-off-by: Arun Ramadoss <arun.ramadoss@microchip.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
24 lines
1.1 KiB
C
24 lines
1.1 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Microchip lan937x dev ops headers
|
|
* Copyright (C) 2019-2022 Microchip Technology Inc.
|
|
*/
|
|
|
|
#ifndef __LAN937X_CFG_H
|
|
#define __LAN937X_CFG_H
|
|
|
|
int lan937x_reset_switch(struct ksz_device *dev);
|
|
int lan937x_setup(struct dsa_switch *ds);
|
|
void lan937x_teardown(struct dsa_switch *ds);
|
|
void lan937x_port_setup(struct ksz_device *dev, int port, bool cpu_port);
|
|
void lan937x_config_cpu_port(struct dsa_switch *ds);
|
|
int lan937x_switch_init(struct ksz_device *dev);
|
|
void lan937x_switch_exit(struct ksz_device *dev);
|
|
int lan937x_r_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 *data);
|
|
int lan937x_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val);
|
|
int lan937x_change_mtu(struct ksz_device *dev, int port, int new_mtu);
|
|
void lan937x_phylink_get_caps(struct ksz_device *dev, int port,
|
|
struct phylink_config *config);
|
|
void lan937x_setup_rgmii_delay(struct ksz_device *dev, int port);
|
|
int lan937x_set_ageing_time(struct ksz_device *dev, unsigned int msecs);
|
|
int lan937x_tc_cbs_set_cinc(struct ksz_device *dev, int port, u32 val);
|
|
#endif
|