Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: hns: add attribute port-rst-offset for dsaf port node

The reset offset for each port in a dsaf is different. The current code is
not so readability. This patch adds configuration named port-rst-offset to
make the code simple and more readability. If this attribute doesn't exist,
default value of this attribute is equal to its port index.

Signed-off-by: Yisen Zhuang <yisen.zhuang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yisen.Zhuang\(Zhuangyuzeng\) and committed by
David S. Miller
850bfa3b 31d4446d

+19 -17
+10
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.c
··· 664 664 665 665 mac_cb->max_frm = MAC_DEFAULT_MTU; 666 666 mac_cb->tx_pause_frm_time = MAC_DEFAULT_PAUSE_TIME; 667 + mac_cb->port_rst_off = mac_cb->mac_id; 667 668 668 669 /* if the dsaf node doesn't contain a port subnode, get phy-handle 669 670 * from dsaf node ··· 693 692 return -EINVAL; 694 693 } 695 694 mac_cb->serdes_ctrl = syscon; 695 + 696 + ret = fwnode_property_read_u32(mac_cb->fw_port, 697 + "port-rst-offset", 698 + &mac_cb->port_rst_off); 699 + if (ret) { 700 + dev_dbg(mac_cb->dev, 701 + "mac%d port-rst-offset not found, use default value.\n", 702 + mac_cb->mac_id); 703 + } 696 704 697 705 syscon = syscon_node_to_regmap( 698 706 of_parse_phandle(to_of_node(mac_cb->fw_port),
+1
drivers/net/ethernet/hisilicon/hns/hns_dsaf_mac.h
··· 318 318 struct regmap *serdes_ctrl; 319 319 struct regmap *cpld_ctrl; 320 320 u32 cpld_ctrl_reg; 321 + u32 port_rst_off; 321 322 struct mac_entry_idx addr_entry_idx[DSAF_MAX_VM_NUM]; 322 323 u8 sfp_prsnt; 323 324 u8 cpld_led_value;
+8 -17
drivers/net/ethernet/hisilicon/hns/hns_dsaf_misc.c
··· 135 135 return; 136 136 137 137 reg_val |= RESET_REQ_OR_DREQ; 138 - 139 - if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) 140 - reg_val |= 0x2082082 << port; 141 - else 142 - reg_val |= 0x2082082 << (dsaf_dev->reset_offset + 6); 138 + reg_val |= 0x2082082 << dsaf_dev->mac_cb[port]->port_rst_off; 143 139 144 140 if (val == 0) 145 141 reg_addr = DSAF_SUB_SC_XGE_RESET_REQ_REG; ··· 154 158 if (port >= DSAF_XGE_NUM) 155 159 return; 156 160 157 - if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) 158 - reg_val |= XGMAC_TRX_CORE_SRST_M << port; 159 - else 160 - reg_val |= XGMAC_TRX_CORE_SRST_M << 161 - (dsaf_dev->reset_offset + 6); 161 + reg_val |= XGMAC_TRX_CORE_SRST_M 162 + << dsaf_dev->mac_cb[port]->port_rst_off; 162 163 163 164 if (val == 0) 164 165 reg_addr = DSAF_SUB_SC_XGE_RESET_REQ_REG; ··· 169 176 { 170 177 u32 reg_val_1; 171 178 u32 reg_val_2; 179 + u32 port_rst_off; 172 180 173 181 if (port >= DSAF_GE_NUM) 174 182 return; 175 183 176 184 if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) { 177 185 reg_val_1 = 0x1 << port; 186 + port_rst_off = dsaf_dev->mac_cb[port]->port_rst_off; 178 187 /* there is difference between V1 and V2 in register.*/ 179 188 if (AE_IS_VER1(dsaf_dev->dsaf_ver)) 180 - reg_val_2 = 0x1041041 << port; 189 + reg_val_2 = 0x1041041 << port_rst_off; 181 190 else 182 - reg_val_2 = 0x2082082 << port; 191 + reg_val_2 = 0x2082082 << port_rst_off; 183 192 184 193 if (val == 0) { 185 194 dsaf_write_sub(dsaf_dev, DSAF_SUB_SC_GE_RESET_REQ1_REG, ··· 221 226 u32 reg_val = 0; 222 227 u32 reg_addr; 223 228 224 - if (!HNS_DSAF_IS_DEBUG(dsaf_dev)) 225 - reg_val |= RESET_REQ_OR_DREQ << port; 226 - else 227 - reg_val |= RESET_REQ_OR_DREQ << 228 - (dsaf_dev->reset_offset + 6); 229 + reg_val |= RESET_REQ_OR_DREQ << dsaf_dev->mac_cb[port]->port_rst_off; 229 230 230 231 if (val == 0) 231 232 reg_addr = DSAF_SUB_SC_PPE_RESET_REQ_REG;