Lines Matching refs:pdata

36 static int xlgmac_disable_rx_csum(struct xlgmac_pdata *pdata)  in xlgmac_disable_rx_csum()  argument
40 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_disable_rx_csum()
43 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_disable_rx_csum()
48 static int xlgmac_enable_rx_csum(struct xlgmac_pdata *pdata) in xlgmac_enable_rx_csum() argument
52 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_enable_rx_csum()
55 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_enable_rx_csum()
60 static int xlgmac_set_mac_address(struct xlgmac_pdata *pdata, const u8 *addr) in xlgmac_set_mac_address() argument
68 writel(mac_addr_hi, pdata->mac_regs + MAC_MACA0HR); in xlgmac_set_mac_address()
69 writel(mac_addr_lo, pdata->mac_regs + MAC_MACA0LR); in xlgmac_set_mac_address()
74 static void xlgmac_set_mac_reg(struct xlgmac_pdata *pdata, in xlgmac_set_mac_reg() argument
94 netif_dbg(pdata, drv, pdata->netdev, in xlgmac_set_mac_reg()
104 writel(mac_addr_hi, pdata->mac_regs + *mac_reg); in xlgmac_set_mac_reg()
106 writel(mac_addr_lo, pdata->mac_regs + *mac_reg); in xlgmac_set_mac_reg()
110 static int xlgmac_enable_rx_vlan_stripping(struct xlgmac_pdata *pdata) in xlgmac_enable_rx_vlan_stripping() argument
114 regval = readl(pdata->mac_regs + MAC_VLANTR); in xlgmac_enable_rx_vlan_stripping()
130 writel(regval, pdata->mac_regs + MAC_VLANTR); in xlgmac_enable_rx_vlan_stripping()
135 static int xlgmac_disable_rx_vlan_stripping(struct xlgmac_pdata *pdata) in xlgmac_disable_rx_vlan_stripping() argument
139 regval = readl(pdata->mac_regs + MAC_VLANTR); in xlgmac_disable_rx_vlan_stripping()
142 writel(regval, pdata->mac_regs + MAC_VLANTR); in xlgmac_disable_rx_vlan_stripping()
147 static int xlgmac_enable_rx_vlan_filtering(struct xlgmac_pdata *pdata) in xlgmac_enable_rx_vlan_filtering() argument
151 regval = readl(pdata->mac_regs + MAC_PFR); in xlgmac_enable_rx_vlan_filtering()
155 writel(regval, pdata->mac_regs + MAC_PFR); in xlgmac_enable_rx_vlan_filtering()
157 regval = readl(pdata->mac_regs + MAC_VLANTR); in xlgmac_enable_rx_vlan_filtering()
175 writel(regval, pdata->mac_regs + MAC_VLANTR); in xlgmac_enable_rx_vlan_filtering()
180 static int xlgmac_disable_rx_vlan_filtering(struct xlgmac_pdata *pdata) in xlgmac_disable_rx_vlan_filtering() argument
184 regval = readl(pdata->mac_regs + MAC_PFR); in xlgmac_disable_rx_vlan_filtering()
188 writel(regval, pdata->mac_regs + MAC_PFR); in xlgmac_disable_rx_vlan_filtering()
217 static int xlgmac_update_vlan_hash_table(struct xlgmac_pdata *pdata) in xlgmac_update_vlan_hash_table() argument
226 for_each_set_bit(vid, pdata->active_vlans, VLAN_N_VID) { in xlgmac_update_vlan_hash_table()
234 regval = readl(pdata->mac_regs + MAC_VLANHTR); in xlgmac_update_vlan_hash_table()
238 writel(regval, pdata->mac_regs + MAC_VLANHTR); in xlgmac_update_vlan_hash_table()
243 static int xlgmac_set_promiscuous_mode(struct xlgmac_pdata *pdata, in xlgmac_set_promiscuous_mode() argument
249 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_PFR), in xlgmac_set_promiscuous_mode()
254 netif_dbg(pdata, drv, pdata->netdev, "%s promiscuous mode\n", in xlgmac_set_promiscuous_mode()
257 regval = readl(pdata->mac_regs + MAC_PFR); in xlgmac_set_promiscuous_mode()
260 writel(regval, pdata->mac_regs + MAC_PFR); in xlgmac_set_promiscuous_mode()
264 xlgmac_disable_rx_vlan_filtering(pdata); in xlgmac_set_promiscuous_mode()
266 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in xlgmac_set_promiscuous_mode()
267 xlgmac_enable_rx_vlan_filtering(pdata); in xlgmac_set_promiscuous_mode()
273 static int xlgmac_set_all_multicast_mode(struct xlgmac_pdata *pdata, in xlgmac_set_all_multicast_mode() argument
279 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_PFR), in xlgmac_set_all_multicast_mode()
284 netif_dbg(pdata, drv, pdata->netdev, "%s allmulti mode\n", in xlgmac_set_all_multicast_mode()
287 regval = readl(pdata->mac_regs + MAC_PFR); in xlgmac_set_all_multicast_mode()
290 writel(regval, pdata->mac_regs + MAC_PFR); in xlgmac_set_all_multicast_mode()
295 static void xlgmac_set_mac_addn_addrs(struct xlgmac_pdata *pdata) in xlgmac_set_mac_addn_addrs() argument
297 struct net_device *netdev = pdata->netdev; in xlgmac_set_mac_addn_addrs()
303 addn_macs = pdata->hw_feat.addn_mac; in xlgmac_set_mac_addn_addrs()
306 xlgmac_set_promiscuous_mode(pdata, 1); in xlgmac_set_mac_addn_addrs()
309 xlgmac_set_mac_reg(pdata, ha, &mac_reg); in xlgmac_set_mac_addn_addrs()
314 xlgmac_set_all_multicast_mode(pdata, 1); in xlgmac_set_mac_addn_addrs()
317 xlgmac_set_mac_reg(pdata, ha, &mac_reg); in xlgmac_set_mac_addn_addrs()
325 xlgmac_set_mac_reg(pdata, NULL, &mac_reg); in xlgmac_set_mac_addn_addrs()
328 static void xlgmac_set_mac_hash_table(struct xlgmac_pdata *pdata) in xlgmac_set_mac_hash_table() argument
332 struct net_device *netdev = pdata->netdev; in xlgmac_set_mac_hash_table()
338 hash_table_shift = 26 - (pdata->hw_feat.hash_table_size >> 7); in xlgmac_set_mac_hash_table()
339 hash_table_count = pdata->hw_feat.hash_table_size / 32; in xlgmac_set_mac_hash_table()
358 writel(hash_table[i], pdata->mac_regs + hash_reg); in xlgmac_set_mac_hash_table()
363 static int xlgmac_add_mac_addresses(struct xlgmac_pdata *pdata) in xlgmac_add_mac_addresses() argument
365 if (pdata->hw_feat.hash_table_size) in xlgmac_add_mac_addresses()
366 xlgmac_set_mac_hash_table(pdata); in xlgmac_add_mac_addresses()
368 xlgmac_set_mac_addn_addrs(pdata); in xlgmac_add_mac_addresses()
373 static void xlgmac_config_mac_address(struct xlgmac_pdata *pdata) in xlgmac_config_mac_address() argument
377 xlgmac_set_mac_address(pdata, pdata->netdev->dev_addr); in xlgmac_config_mac_address()
380 if (pdata->hw_feat.hash_table_size) { in xlgmac_config_mac_address()
381 regval = readl(pdata->mac_regs + MAC_PFR); in xlgmac_config_mac_address()
388 writel(regval, pdata->mac_regs + MAC_PFR); in xlgmac_config_mac_address()
392 static void xlgmac_config_jumbo_enable(struct xlgmac_pdata *pdata) in xlgmac_config_jumbo_enable() argument
397 val = (pdata->netdev->mtu > XLGMAC_STD_PACKET_MTU) ? 1 : 0; in xlgmac_config_jumbo_enable()
399 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_config_jumbo_enable()
402 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_config_jumbo_enable()
405 static void xlgmac_config_checksum_offload(struct xlgmac_pdata *pdata) in xlgmac_config_checksum_offload() argument
407 if (pdata->netdev->features & NETIF_F_RXCSUM) in xlgmac_config_checksum_offload()
408 xlgmac_enable_rx_csum(pdata); in xlgmac_config_checksum_offload()
410 xlgmac_disable_rx_csum(pdata); in xlgmac_config_checksum_offload()
413 static void xlgmac_config_vlan_support(struct xlgmac_pdata *pdata) in xlgmac_config_vlan_support() argument
417 regval = readl(pdata->mac_regs + MAC_VLANIR); in xlgmac_config_vlan_support()
423 writel(regval, pdata->mac_regs + MAC_VLANIR); in xlgmac_config_vlan_support()
426 xlgmac_update_vlan_hash_table(pdata); in xlgmac_config_vlan_support()
428 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_FILTER) in xlgmac_config_vlan_support()
429 xlgmac_enable_rx_vlan_filtering(pdata); in xlgmac_config_vlan_support()
431 xlgmac_disable_rx_vlan_filtering(pdata); in xlgmac_config_vlan_support()
433 if (pdata->netdev->features & NETIF_F_HW_VLAN_CTAG_RX) in xlgmac_config_vlan_support()
434 xlgmac_enable_rx_vlan_stripping(pdata); in xlgmac_config_vlan_support()
436 xlgmac_disable_rx_vlan_stripping(pdata); in xlgmac_config_vlan_support()
439 static int xlgmac_config_rx_mode(struct xlgmac_pdata *pdata) in xlgmac_config_rx_mode() argument
441 struct net_device *netdev = pdata->netdev; in xlgmac_config_rx_mode()
447 xlgmac_set_promiscuous_mode(pdata, pr_mode); in xlgmac_config_rx_mode()
448 xlgmac_set_all_multicast_mode(pdata, am_mode); in xlgmac_config_rx_mode()
450 xlgmac_add_mac_addresses(pdata); in xlgmac_config_rx_mode()
455 static void xlgmac_prepare_tx_stop(struct xlgmac_pdata *pdata, in xlgmac_prepare_tx_stop() argument
481 tx_status = readl(pdata->mac_regs + tx_dsr); in xlgmac_prepare_tx_stop()
492 netdev_info(pdata->netdev, in xlgmac_prepare_tx_stop()
497 static void xlgmac_enable_tx(struct xlgmac_pdata *pdata) in xlgmac_enable_tx() argument
504 channel = pdata->channel_head; in xlgmac_enable_tx()
505 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_enable_tx()
516 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_enable_tx()
517 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_enable_tx()
521 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_enable_tx()
525 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_enable_tx()
528 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_enable_tx()
531 static void xlgmac_disable_tx(struct xlgmac_pdata *pdata) in xlgmac_disable_tx() argument
538 channel = pdata->channel_head; in xlgmac_disable_tx()
539 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_disable_tx()
543 xlgmac_prepare_tx_stop(pdata, channel); in xlgmac_disable_tx()
547 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_disable_tx()
550 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_disable_tx()
553 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_disable_tx()
554 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_disable_tx()
557 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_disable_tx()
561 channel = pdata->channel_head; in xlgmac_disable_tx()
562 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_disable_tx()
573 static void xlgmac_prepare_rx_stop(struct xlgmac_pdata *pdata, in xlgmac_prepare_rx_stop() argument
585 rx_status = readl(XLGMAC_MTL_REG(pdata, queue, MTL_Q_RQDR)); in xlgmac_prepare_rx_stop()
597 netdev_info(pdata->netdev, in xlgmac_prepare_rx_stop()
602 static void xlgmac_enable_rx(struct xlgmac_pdata *pdata) in xlgmac_enable_rx() argument
608 channel = pdata->channel_head; in xlgmac_enable_rx()
609 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_enable_rx()
621 for (i = 0; i < pdata->rx_q_count; i++) in xlgmac_enable_rx()
623 writel(regval, pdata->mac_regs + MAC_RQC0R); in xlgmac_enable_rx()
626 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_enable_rx()
635 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_enable_rx()
638 static void xlgmac_disable_rx(struct xlgmac_pdata *pdata) in xlgmac_disable_rx() argument
645 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_disable_rx()
654 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_disable_rx()
657 for (i = 0; i < pdata->rx_q_count; i++) in xlgmac_disable_rx()
658 xlgmac_prepare_rx_stop(pdata, i); in xlgmac_disable_rx()
661 writel(0, pdata->mac_regs + MAC_RQC0R); in xlgmac_disable_rx()
664 channel = pdata->channel_head; in xlgmac_disable_rx()
665 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_disable_rx()
679 struct xlgmac_pdata *pdata = channel->pdata; in xlgmac_tx_start_xmit() local
693 if (pdata->tx_usecs && !channel->tx_timer_active) { in xlgmac_tx_start_xmit()
696 jiffies + usecs_to_jiffies(pdata->tx_usecs)); in xlgmac_tx_start_xmit()
704 struct xlgmac_pdata *pdata = channel->pdata; in xlgmac_dev_xmit() local
748 if (!pdata->tx_frames) in xlgmac_dev_xmit()
750 else if (pkt_info->tx_packets > pdata->tx_frames) in xlgmac_dev_xmit()
752 else if ((ring->coalesce_count % pdata->tx_frames) < in xlgmac_dev_xmit()
764 netif_dbg(pdata, tx_queued, pdata->netdev, in xlgmac_dev_xmit()
793 netif_dbg(pdata, tx_queued, pdata->netdev, in xlgmac_dev_xmit()
844 pdata->stats.tx_vlan_packets++; in xlgmac_dev_xmit()
896 pdata->stats.tx_tso_packets++; in xlgmac_dev_xmit()
990 if (netif_msg_tx_queued(pdata)) in xlgmac_dev_xmit()
991 xlgmac_dump_tx_desc(pdata, ring, start_index, in xlgmac_dev_xmit()
999 netif_xmit_stopped(netdev_get_tx_queue(pdata->netdev, in xlgmac_dev_xmit()
1082 static void xlgmac_rx_desc_reset(struct xlgmac_pdata *pdata, in xlgmac_rx_desc_reset() argument
1087 unsigned int rx_frames = pdata->rx_frames; in xlgmac_rx_desc_reset()
1088 unsigned int rx_usecs = pdata->rx_usecs; in xlgmac_rx_desc_reset()
1141 struct xlgmac_pdata *pdata = channel->pdata; in xlgmac_rx_desc_init() local
1152 xlgmac_rx_desc_reset(pdata, desc_data, i); in xlgmac_rx_desc_init()
1188 static int xlgmac_disable_tx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_disable_tx_flow_control() argument
1195 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_disable_tx_flow_control()
1196 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_disable_tx_flow_control()
1199 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_disable_tx_flow_control()
1204 q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); in xlgmac_disable_tx_flow_control()
1207 regval = readl(pdata->mac_regs + reg); in xlgmac_disable_tx_flow_control()
1212 writel(regval, pdata->mac_regs + reg); in xlgmac_disable_tx_flow_control()
1220 static int xlgmac_enable_tx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_enable_tx_flow_control() argument
1227 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_enable_tx_flow_control()
1228 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_enable_tx_flow_control()
1231 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_enable_tx_flow_control()
1236 q_count = min_t(unsigned int, pdata->tx_q_count, max_q_count); in xlgmac_enable_tx_flow_control()
1239 regval = readl(pdata->mac_regs + reg); in xlgmac_enable_tx_flow_control()
1248 writel(regval, pdata->mac_regs + reg); in xlgmac_enable_tx_flow_control()
1256 static int xlgmac_disable_rx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_disable_rx_flow_control() argument
1260 regval = readl(pdata->mac_regs + MAC_RFCR); in xlgmac_disable_rx_flow_control()
1263 writel(regval, pdata->mac_regs + MAC_RFCR); in xlgmac_disable_rx_flow_control()
1268 static int xlgmac_enable_rx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_enable_rx_flow_control() argument
1272 regval = readl(pdata->mac_regs + MAC_RFCR); in xlgmac_enable_rx_flow_control()
1275 writel(regval, pdata->mac_regs + MAC_RFCR); in xlgmac_enable_rx_flow_control()
1280 static int xlgmac_config_tx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_config_tx_flow_control() argument
1282 if (pdata->tx_pause) in xlgmac_config_tx_flow_control()
1283 xlgmac_enable_tx_flow_control(pdata); in xlgmac_config_tx_flow_control()
1285 xlgmac_disable_tx_flow_control(pdata); in xlgmac_config_tx_flow_control()
1290 static int xlgmac_config_rx_flow_control(struct xlgmac_pdata *pdata) in xlgmac_config_rx_flow_control() argument
1292 if (pdata->rx_pause) in xlgmac_config_rx_flow_control()
1293 xlgmac_enable_rx_flow_control(pdata); in xlgmac_config_rx_flow_control()
1295 xlgmac_disable_rx_flow_control(pdata); in xlgmac_config_rx_flow_control()
1300 static int xlgmac_config_rx_coalesce(struct xlgmac_pdata *pdata) in xlgmac_config_rx_coalesce() argument
1306 channel = pdata->channel_head; in xlgmac_config_rx_coalesce()
1307 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_rx_coalesce()
1314 pdata->rx_riwt); in xlgmac_config_rx_coalesce()
1321 static void xlgmac_config_flow_control(struct xlgmac_pdata *pdata) in xlgmac_config_flow_control() argument
1323 xlgmac_config_tx_flow_control(pdata); in xlgmac_config_flow_control()
1324 xlgmac_config_rx_flow_control(pdata); in xlgmac_config_flow_control()
1327 static void xlgmac_config_rx_fep_enable(struct xlgmac_pdata *pdata) in xlgmac_config_rx_fep_enable() argument
1332 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_rx_fep_enable()
1333 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fep_enable()
1336 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fep_enable()
1340 static void xlgmac_config_rx_fup_enable(struct xlgmac_pdata *pdata) in xlgmac_config_rx_fup_enable() argument
1345 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_rx_fup_enable()
1346 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fup_enable()
1349 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fup_enable()
1353 static int xlgmac_config_tx_coalesce(struct xlgmac_pdata *pdata) in xlgmac_config_tx_coalesce() argument
1358 static void xlgmac_config_rx_buffer_size(struct xlgmac_pdata *pdata) in xlgmac_config_rx_buffer_size() argument
1364 channel = pdata->channel_head; in xlgmac_config_rx_buffer_size()
1365 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_rx_buffer_size()
1372 pdata->rx_buf_size); in xlgmac_config_rx_buffer_size()
1377 static void xlgmac_config_tso_mode(struct xlgmac_pdata *pdata) in xlgmac_config_tso_mode() argument
1383 channel = pdata->channel_head; in xlgmac_config_tso_mode()
1384 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_tso_mode()
1388 if (pdata->hw_feat.tso) { in xlgmac_config_tso_mode()
1397 static void xlgmac_config_sph_mode(struct xlgmac_pdata *pdata) in xlgmac_config_sph_mode() argument
1403 channel = pdata->channel_head; in xlgmac_config_sph_mode()
1404 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_sph_mode()
1414 regval = readl(pdata->mac_regs + MAC_RCR); in xlgmac_config_sph_mode()
1418 writel(regval, pdata->mac_regs + MAC_RCR); in xlgmac_config_sph_mode()
1421 static unsigned int xlgmac_usec_to_riwt(struct xlgmac_pdata *pdata, in xlgmac_usec_to_riwt() argument
1427 rate = pdata->sysclk_rate; in xlgmac_usec_to_riwt()
1439 static unsigned int xlgmac_riwt_to_usec(struct xlgmac_pdata *pdata, in xlgmac_riwt_to_usec() argument
1445 rate = pdata->sysclk_rate; in xlgmac_riwt_to_usec()
1457 static int xlgmac_config_rx_threshold(struct xlgmac_pdata *pdata, in xlgmac_config_rx_threshold() argument
1463 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_rx_threshold()
1464 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_threshold()
1467 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_threshold()
1473 static void xlgmac_config_mtl_mode(struct xlgmac_pdata *pdata) in xlgmac_config_mtl_mode() argument
1479 regval = readl(pdata->mac_regs + MTL_OMR); in xlgmac_config_mtl_mode()
1482 writel(regval, pdata->mac_regs + MTL_OMR); in xlgmac_config_mtl_mode()
1485 for (i = 0; i < pdata->hw_feat.tc_cnt; i++) { in xlgmac_config_mtl_mode()
1486 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_TC_ETSCR)); in xlgmac_config_mtl_mode()
1489 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_TC_ETSCR)); in xlgmac_config_mtl_mode()
1491 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_TC_QWR)); in xlgmac_config_mtl_mode()
1494 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_TC_QWR)); in xlgmac_config_mtl_mode()
1498 regval = readl(pdata->mac_regs + MTL_OMR); in xlgmac_config_mtl_mode()
1501 writel(regval, pdata->mac_regs + MTL_OMR); in xlgmac_config_mtl_mode()
1504 static void xlgmac_config_queue_mapping(struct xlgmac_pdata *pdata) in xlgmac_config_queue_mapping() argument
1515 qptc = pdata->tx_q_count / pdata->hw_feat.tc_cnt; in xlgmac_config_queue_mapping()
1516 qptc_extra = pdata->tx_q_count % pdata->hw_feat.tc_cnt; in xlgmac_config_queue_mapping()
1518 for (i = 0, queue = 0; i < pdata->hw_feat.tc_cnt; i++) { in xlgmac_config_queue_mapping()
1520 netif_dbg(pdata, drv, pdata->netdev, in xlgmac_config_queue_mapping()
1522 regval = readl(XLGMAC_MTL_REG(pdata, queue, in xlgmac_config_queue_mapping()
1528 writel(regval, XLGMAC_MTL_REG(pdata, queue, in xlgmac_config_queue_mapping()
1534 netif_dbg(pdata, drv, pdata->netdev, in xlgmac_config_queue_mapping()
1536 regval = readl(XLGMAC_MTL_REG(pdata, queue, in xlgmac_config_queue_mapping()
1542 writel(regval, XLGMAC_MTL_REG(pdata, queue, in xlgmac_config_queue_mapping()
1550 pdata->rx_q_count); in xlgmac_config_queue_mapping()
1559 netif_dbg(pdata, drv, pdata->netdev, in xlgmac_config_queue_mapping()
1566 netif_dbg(pdata, drv, pdata->netdev, in xlgmac_config_queue_mapping()
1577 writel(regval, pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1586 regval = readl(pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1589 writel(regval, pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1592 regval = readl(pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1595 writel(regval, pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1598 regval = readl(pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1601 writel(regval, pdata->mac_regs + reg); in xlgmac_config_queue_mapping()
1630 static void xlgmac_config_tx_fifo_size(struct xlgmac_pdata *pdata) in xlgmac_config_tx_fifo_size() argument
1637 pdata->hw_feat.tx_fifo_size, in xlgmac_config_tx_fifo_size()
1638 pdata->tx_q_count); in xlgmac_config_tx_fifo_size()
1640 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_config_tx_fifo_size()
1641 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tx_fifo_size()
1644 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tx_fifo_size()
1647 netif_info(pdata, drv, pdata->netdev, in xlgmac_config_tx_fifo_size()
1649 pdata->tx_q_count, ((fifo_size + 1) * 256)); in xlgmac_config_tx_fifo_size()
1652 static void xlgmac_config_rx_fifo_size(struct xlgmac_pdata *pdata) in xlgmac_config_rx_fifo_size() argument
1659 pdata->hw_feat.rx_fifo_size, in xlgmac_config_rx_fifo_size()
1660 pdata->rx_q_count); in xlgmac_config_rx_fifo_size()
1662 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_rx_fifo_size()
1663 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fifo_size()
1666 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rx_fifo_size()
1669 netif_info(pdata, drv, pdata->netdev, in xlgmac_config_rx_fifo_size()
1671 pdata->rx_q_count, ((fifo_size + 1) * 256)); in xlgmac_config_rx_fifo_size()
1674 static void xlgmac_config_flow_control_threshold(struct xlgmac_pdata *pdata) in xlgmac_config_flow_control_threshold() argument
1679 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_flow_control_threshold()
1680 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQFCR)); in xlgmac_config_flow_control_threshold()
1687 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQFCR)); in xlgmac_config_flow_control_threshold()
1691 static int xlgmac_config_tx_threshold(struct xlgmac_pdata *pdata, in xlgmac_config_tx_threshold() argument
1697 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_config_tx_threshold()
1698 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tx_threshold()
1701 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tx_threshold()
1707 static int xlgmac_config_rsf_mode(struct xlgmac_pdata *pdata, in xlgmac_config_rsf_mode() argument
1713 for (i = 0; i < pdata->rx_q_count; i++) { in xlgmac_config_rsf_mode()
1714 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rsf_mode()
1717 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_RQOMR)); in xlgmac_config_rsf_mode()
1723 static int xlgmac_config_tsf_mode(struct xlgmac_pdata *pdata, in xlgmac_config_tsf_mode() argument
1729 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_config_tsf_mode()
1730 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tsf_mode()
1733 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_config_tsf_mode()
1739 static int xlgmac_config_osp_mode(struct xlgmac_pdata *pdata) in xlgmac_config_osp_mode() argument
1745 channel = pdata->channel_head; in xlgmac_config_osp_mode()
1746 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_osp_mode()
1753 pdata->tx_osp_mode); in xlgmac_config_osp_mode()
1760 static int xlgmac_config_pblx8(struct xlgmac_pdata *pdata) in xlgmac_config_pblx8() argument
1766 channel = pdata->channel_head; in xlgmac_config_pblx8()
1767 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_pblx8()
1771 pdata->pblx8); in xlgmac_config_pblx8()
1778 static int xlgmac_get_tx_pbl_val(struct xlgmac_pdata *pdata) in xlgmac_get_tx_pbl_val() argument
1782 regval = readl(XLGMAC_DMA_REG(pdata->channel_head, DMA_CH_TCR)); in xlgmac_get_tx_pbl_val()
1788 static int xlgmac_config_tx_pbl_val(struct xlgmac_pdata *pdata) in xlgmac_config_tx_pbl_val() argument
1794 channel = pdata->channel_head; in xlgmac_config_tx_pbl_val()
1795 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_tx_pbl_val()
1802 pdata->tx_pbl); in xlgmac_config_tx_pbl_val()
1809 static int xlgmac_get_rx_pbl_val(struct xlgmac_pdata *pdata) in xlgmac_get_rx_pbl_val() argument
1813 regval = readl(XLGMAC_DMA_REG(pdata->channel_head, DMA_CH_RCR)); in xlgmac_get_rx_pbl_val()
1819 static int xlgmac_config_rx_pbl_val(struct xlgmac_pdata *pdata) in xlgmac_config_rx_pbl_val() argument
1825 channel = pdata->channel_head; in xlgmac_config_rx_pbl_val()
1826 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_config_rx_pbl_val()
1833 pdata->rx_pbl); in xlgmac_config_rx_pbl_val()
1840 static u64 xlgmac_mmc_read(struct xlgmac_pdata *pdata, unsigned int reg_lo) in xlgmac_mmc_read() argument
1858 val = (u64)readl(pdata->mac_regs + reg_lo); in xlgmac_mmc_read()
1861 val |= ((u64)readl(pdata->mac_regs + reg_lo + 4) << 32); in xlgmac_mmc_read()
1866 static void xlgmac_tx_mmc_int(struct xlgmac_pdata *pdata) in xlgmac_tx_mmc_int() argument
1868 unsigned int mmc_isr = readl(pdata->mac_regs + MMC_TISR); in xlgmac_tx_mmc_int()
1869 struct xlgmac_stats *stats = &pdata->stats; in xlgmac_tx_mmc_int()
1875 xlgmac_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); in xlgmac_tx_mmc_int()
1881 xlgmac_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); in xlgmac_tx_mmc_int()
1887 xlgmac_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); in xlgmac_tx_mmc_int()
1893 xlgmac_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); in xlgmac_tx_mmc_int()
1899 xlgmac_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); in xlgmac_tx_mmc_int()
1905 xlgmac_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); in xlgmac_tx_mmc_int()
1911 xlgmac_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); in xlgmac_tx_mmc_int()
1917 xlgmac_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); in xlgmac_tx_mmc_int()
1923 xlgmac_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); in xlgmac_tx_mmc_int()
1929 xlgmac_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); in xlgmac_tx_mmc_int()
1935 xlgmac_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); in xlgmac_tx_mmc_int()
1941 xlgmac_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); in xlgmac_tx_mmc_int()
1947 xlgmac_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); in xlgmac_tx_mmc_int()
1953 xlgmac_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); in xlgmac_tx_mmc_int()
1959 xlgmac_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); in xlgmac_tx_mmc_int()
1965 xlgmac_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); in xlgmac_tx_mmc_int()
1971 xlgmac_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); in xlgmac_tx_mmc_int()
1977 xlgmac_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); in xlgmac_tx_mmc_int()
1980 static void xlgmac_rx_mmc_int(struct xlgmac_pdata *pdata) in xlgmac_rx_mmc_int() argument
1982 unsigned int mmc_isr = readl(pdata->mac_regs + MMC_RISR); in xlgmac_rx_mmc_int()
1983 struct xlgmac_stats *stats = &pdata->stats; in xlgmac_rx_mmc_int()
1989 xlgmac_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); in xlgmac_rx_mmc_int()
1995 xlgmac_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); in xlgmac_rx_mmc_int()
2001 xlgmac_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); in xlgmac_rx_mmc_int()
2007 xlgmac_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); in xlgmac_rx_mmc_int()
2013 xlgmac_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); in xlgmac_rx_mmc_int()
2019 xlgmac_mmc_read(pdata, MMC_RXCRCERROR_LO); in xlgmac_rx_mmc_int()
2025 xlgmac_mmc_read(pdata, MMC_RXRUNTERROR); in xlgmac_rx_mmc_int()
2031 xlgmac_mmc_read(pdata, MMC_RXJABBERERROR); in xlgmac_rx_mmc_int()
2037 xlgmac_mmc_read(pdata, MMC_RXUNDERSIZE_G); in xlgmac_rx_mmc_int()
2043 xlgmac_mmc_read(pdata, MMC_RXOVERSIZE_G); in xlgmac_rx_mmc_int()
2049 xlgmac_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); in xlgmac_rx_mmc_int()
2055 xlgmac_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); in xlgmac_rx_mmc_int()
2061 xlgmac_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); in xlgmac_rx_mmc_int()
2067 xlgmac_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); in xlgmac_rx_mmc_int()
2073 xlgmac_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); in xlgmac_rx_mmc_int()
2079 xlgmac_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); in xlgmac_rx_mmc_int()
2085 xlgmac_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); in xlgmac_rx_mmc_int()
2091 xlgmac_mmc_read(pdata, MMC_RXLENGTHERROR_LO); in xlgmac_rx_mmc_int()
2097 xlgmac_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); in xlgmac_rx_mmc_int()
2103 xlgmac_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); in xlgmac_rx_mmc_int()
2109 xlgmac_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); in xlgmac_rx_mmc_int()
2115 xlgmac_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); in xlgmac_rx_mmc_int()
2121 xlgmac_mmc_read(pdata, MMC_RXWATCHDOGERROR); in xlgmac_rx_mmc_int()
2124 static void xlgmac_read_mmc_stats(struct xlgmac_pdata *pdata) in xlgmac_read_mmc_stats() argument
2126 struct xlgmac_stats *stats = &pdata->stats; in xlgmac_read_mmc_stats()
2130 regval = readl(pdata->mac_regs + MMC_CR); in xlgmac_read_mmc_stats()
2133 writel(regval, pdata->mac_regs + MMC_CR); in xlgmac_read_mmc_stats()
2136 xlgmac_mmc_read(pdata, MMC_TXOCTETCOUNT_GB_LO); in xlgmac_read_mmc_stats()
2139 xlgmac_mmc_read(pdata, MMC_TXFRAMECOUNT_GB_LO); in xlgmac_read_mmc_stats()
2142 xlgmac_mmc_read(pdata, MMC_TXBROADCASTFRAMES_G_LO); in xlgmac_read_mmc_stats()
2145 xlgmac_mmc_read(pdata, MMC_TXMULTICASTFRAMES_G_LO); in xlgmac_read_mmc_stats()
2148 xlgmac_mmc_read(pdata, MMC_TX64OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2151 xlgmac_mmc_read(pdata, MMC_TX65TO127OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2154 xlgmac_mmc_read(pdata, MMC_TX128TO255OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2157 xlgmac_mmc_read(pdata, MMC_TX256TO511OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2160 xlgmac_mmc_read(pdata, MMC_TX512TO1023OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2163 xlgmac_mmc_read(pdata, MMC_TX1024TOMAXOCTETS_GB_LO); in xlgmac_read_mmc_stats()
2166 xlgmac_mmc_read(pdata, MMC_TXUNICASTFRAMES_GB_LO); in xlgmac_read_mmc_stats()
2169 xlgmac_mmc_read(pdata, MMC_TXMULTICASTFRAMES_GB_LO); in xlgmac_read_mmc_stats()
2172 xlgmac_mmc_read(pdata, MMC_TXBROADCASTFRAMES_GB_LO); in xlgmac_read_mmc_stats()
2175 xlgmac_mmc_read(pdata, MMC_TXUNDERFLOWERROR_LO); in xlgmac_read_mmc_stats()
2178 xlgmac_mmc_read(pdata, MMC_TXOCTETCOUNT_G_LO); in xlgmac_read_mmc_stats()
2181 xlgmac_mmc_read(pdata, MMC_TXFRAMECOUNT_G_LO); in xlgmac_read_mmc_stats()
2184 xlgmac_mmc_read(pdata, MMC_TXPAUSEFRAMES_LO); in xlgmac_read_mmc_stats()
2187 xlgmac_mmc_read(pdata, MMC_TXVLANFRAMES_G_LO); in xlgmac_read_mmc_stats()
2190 xlgmac_mmc_read(pdata, MMC_RXFRAMECOUNT_GB_LO); in xlgmac_read_mmc_stats()
2193 xlgmac_mmc_read(pdata, MMC_RXOCTETCOUNT_GB_LO); in xlgmac_read_mmc_stats()
2196 xlgmac_mmc_read(pdata, MMC_RXOCTETCOUNT_G_LO); in xlgmac_read_mmc_stats()
2199 xlgmac_mmc_read(pdata, MMC_RXBROADCASTFRAMES_G_LO); in xlgmac_read_mmc_stats()
2202 xlgmac_mmc_read(pdata, MMC_RXMULTICASTFRAMES_G_LO); in xlgmac_read_mmc_stats()
2205 xlgmac_mmc_read(pdata, MMC_RXCRCERROR_LO); in xlgmac_read_mmc_stats()
2208 xlgmac_mmc_read(pdata, MMC_RXRUNTERROR); in xlgmac_read_mmc_stats()
2211 xlgmac_mmc_read(pdata, MMC_RXJABBERERROR); in xlgmac_read_mmc_stats()
2214 xlgmac_mmc_read(pdata, MMC_RXUNDERSIZE_G); in xlgmac_read_mmc_stats()
2217 xlgmac_mmc_read(pdata, MMC_RXOVERSIZE_G); in xlgmac_read_mmc_stats()
2220 xlgmac_mmc_read(pdata, MMC_RX64OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2223 xlgmac_mmc_read(pdata, MMC_RX65TO127OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2226 xlgmac_mmc_read(pdata, MMC_RX128TO255OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2229 xlgmac_mmc_read(pdata, MMC_RX256TO511OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2232 xlgmac_mmc_read(pdata, MMC_RX512TO1023OCTETS_GB_LO); in xlgmac_read_mmc_stats()
2235 xlgmac_mmc_read(pdata, MMC_RX1024TOMAXOCTETS_GB_LO); in xlgmac_read_mmc_stats()
2238 xlgmac_mmc_read(pdata, MMC_RXUNICASTFRAMES_G_LO); in xlgmac_read_mmc_stats()
2241 xlgmac_mmc_read(pdata, MMC_RXLENGTHERROR_LO); in xlgmac_read_mmc_stats()
2244 xlgmac_mmc_read(pdata, MMC_RXOUTOFRANGETYPE_LO); in xlgmac_read_mmc_stats()
2247 xlgmac_mmc_read(pdata, MMC_RXPAUSEFRAMES_LO); in xlgmac_read_mmc_stats()
2250 xlgmac_mmc_read(pdata, MMC_RXFIFOOVERFLOW_LO); in xlgmac_read_mmc_stats()
2253 xlgmac_mmc_read(pdata, MMC_RXVLANFRAMES_GB_LO); in xlgmac_read_mmc_stats()
2256 xlgmac_mmc_read(pdata, MMC_RXWATCHDOGERROR); in xlgmac_read_mmc_stats()
2259 regval = readl(pdata->mac_regs + MMC_CR); in xlgmac_read_mmc_stats()
2262 writel(regval, pdata->mac_regs + MMC_CR); in xlgmac_read_mmc_stats()
2265 static void xlgmac_config_mmc(struct xlgmac_pdata *pdata) in xlgmac_config_mmc() argument
2269 regval = readl(pdata->mac_regs + MMC_CR); in xlgmac_config_mmc()
2276 writel(regval, pdata->mac_regs + MMC_CR); in xlgmac_config_mmc()
2279 static int xlgmac_write_rss_reg(struct xlgmac_pdata *pdata, unsigned int type, in xlgmac_write_rss_reg() argument
2286 mutex_lock(&pdata->rss_mutex); in xlgmac_write_rss_reg()
2288 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_RSSAR), in xlgmac_write_rss_reg()
2295 writel(val, pdata->mac_regs + MAC_RSSDR); in xlgmac_write_rss_reg()
2297 regval = readl(pdata->mac_regs + MAC_RSSAR); in xlgmac_write_rss_reg()
2306 writel(regval, pdata->mac_regs + MAC_RSSAR); in xlgmac_write_rss_reg()
2310 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_RSSAR), in xlgmac_write_rss_reg()
2322 mutex_unlock(&pdata->rss_mutex); in xlgmac_write_rss_reg()
2327 static int xlgmac_write_rss_hash_key(struct xlgmac_pdata *pdata) in xlgmac_write_rss_hash_key() argument
2329 unsigned int key_regs = sizeof(pdata->rss_key) / sizeof(u32); in xlgmac_write_rss_hash_key()
2330 unsigned int *key = (unsigned int *)&pdata->rss_key; in xlgmac_write_rss_hash_key()
2334 ret = xlgmac_write_rss_reg(pdata, XLGMAC_RSS_HASH_KEY_TYPE, in xlgmac_write_rss_hash_key()
2343 static int xlgmac_write_rss_lookup_table(struct xlgmac_pdata *pdata) in xlgmac_write_rss_lookup_table() argument
2348 for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) { in xlgmac_write_rss_lookup_table()
2349 ret = xlgmac_write_rss_reg(pdata, in xlgmac_write_rss_lookup_table()
2351 pdata->rss_table[i]); in xlgmac_write_rss_lookup_table()
2359 static int xlgmac_set_rss_hash_key(struct xlgmac_pdata *pdata, const u8 *key) in xlgmac_set_rss_hash_key() argument
2361 memcpy(pdata->rss_key, key, sizeof(pdata->rss_key)); in xlgmac_set_rss_hash_key()
2363 return xlgmac_write_rss_hash_key(pdata); in xlgmac_set_rss_hash_key()
2366 static int xlgmac_set_rss_lookup_table(struct xlgmac_pdata *pdata, in xlgmac_set_rss_lookup_table() argument
2372 for (i = 0; i < ARRAY_SIZE(pdata->rss_table); i++) { in xlgmac_set_rss_lookup_table()
2374 pdata->rss_table[i] = XLGMAC_SET_REG_BITS( in xlgmac_set_rss_lookup_table()
2375 pdata->rss_table[i], in xlgmac_set_rss_lookup_table()
2381 return xlgmac_write_rss_lookup_table(pdata); in xlgmac_set_rss_lookup_table()
2384 static int xlgmac_enable_rss(struct xlgmac_pdata *pdata) in xlgmac_enable_rss() argument
2389 if (!pdata->hw_feat.rss) in xlgmac_enable_rss()
2393 ret = xlgmac_write_rss_hash_key(pdata); in xlgmac_enable_rss()
2398 ret = xlgmac_write_rss_lookup_table(pdata); in xlgmac_enable_rss()
2403 writel(pdata->rss_options, pdata->mac_regs + MAC_RSSCR); in xlgmac_enable_rss()
2406 regval = readl(pdata->mac_regs + MAC_RSSCR); in xlgmac_enable_rss()
2409 writel(regval, pdata->mac_regs + MAC_RSSCR); in xlgmac_enable_rss()
2414 static int xlgmac_disable_rss(struct xlgmac_pdata *pdata) in xlgmac_disable_rss() argument
2418 if (!pdata->hw_feat.rss) in xlgmac_disable_rss()
2421 regval = readl(pdata->mac_regs + MAC_RSSCR); in xlgmac_disable_rss()
2424 writel(regval, pdata->mac_regs + MAC_RSSCR); in xlgmac_disable_rss()
2429 static void xlgmac_config_rss(struct xlgmac_pdata *pdata) in xlgmac_config_rss() argument
2433 if (!pdata->hw_feat.rss) in xlgmac_config_rss()
2436 if (pdata->netdev->features & NETIF_F_RXHASH) in xlgmac_config_rss()
2437 ret = xlgmac_enable_rss(pdata); in xlgmac_config_rss()
2439 ret = xlgmac_disable_rss(pdata); in xlgmac_config_rss()
2442 netdev_err(pdata->netdev, in xlgmac_config_rss()
2446 static void xlgmac_enable_dma_interrupts(struct xlgmac_pdata *pdata) in xlgmac_enable_dma_interrupts() argument
2452 channel = pdata->channel_head; in xlgmac_enable_dma_interrupts()
2453 for (i = 0; i < pdata->channel_count; i++, channel++) { in xlgmac_enable_dma_interrupts()
2481 if (!pdata->per_channel_irq) in xlgmac_enable_dma_interrupts()
2499 if (!pdata->per_channel_irq) in xlgmac_enable_dma_interrupts()
2511 static void xlgmac_enable_mtl_interrupts(struct xlgmac_pdata *pdata) in xlgmac_enable_mtl_interrupts() argument
2516 q_count = max(pdata->hw_feat.tx_q_cnt, pdata->hw_feat.rx_q_cnt); in xlgmac_enable_mtl_interrupts()
2519 mtl_q_isr = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_ISR)); in xlgmac_enable_mtl_interrupts()
2520 writel(mtl_q_isr, XLGMAC_MTL_REG(pdata, i, MTL_Q_ISR)); in xlgmac_enable_mtl_interrupts()
2523 writel(0, XLGMAC_MTL_REG(pdata, i, MTL_Q_IER)); in xlgmac_enable_mtl_interrupts()
2527 static void xlgmac_enable_mac_interrupts(struct xlgmac_pdata *pdata) in xlgmac_enable_mac_interrupts() argument
2536 writel(mac_ier, pdata->mac_regs + MAC_IER); in xlgmac_enable_mac_interrupts()
2539 regval = readl(pdata->mac_regs + MMC_RIER); in xlgmac_enable_mac_interrupts()
2542 writel(regval, pdata->mac_regs + MMC_RIER); in xlgmac_enable_mac_interrupts()
2543 regval = readl(pdata->mac_regs + MMC_TIER); in xlgmac_enable_mac_interrupts()
2546 writel(regval, pdata->mac_regs + MMC_TIER); in xlgmac_enable_mac_interrupts()
2549 static int xlgmac_set_xlgmii_25000_speed(struct xlgmac_pdata *pdata) in xlgmac_set_xlgmii_25000_speed() argument
2553 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_TCR), in xlgmac_set_xlgmii_25000_speed()
2558 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_25000_speed()
2561 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_25000_speed()
2566 static int xlgmac_set_xlgmii_40000_speed(struct xlgmac_pdata *pdata) in xlgmac_set_xlgmii_40000_speed() argument
2570 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_TCR), in xlgmac_set_xlgmii_40000_speed()
2575 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_40000_speed()
2578 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_40000_speed()
2583 static int xlgmac_set_xlgmii_50000_speed(struct xlgmac_pdata *pdata) in xlgmac_set_xlgmii_50000_speed() argument
2587 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_TCR), in xlgmac_set_xlgmii_50000_speed()
2592 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_50000_speed()
2595 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_50000_speed()
2600 static int xlgmac_set_xlgmii_100000_speed(struct xlgmac_pdata *pdata) in xlgmac_set_xlgmii_100000_speed() argument
2604 regval = XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + MAC_TCR), in xlgmac_set_xlgmii_100000_speed()
2609 regval = readl(pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_100000_speed()
2612 writel(regval, pdata->mac_regs + MAC_TCR); in xlgmac_set_xlgmii_100000_speed()
2617 static void xlgmac_config_mac_speed(struct xlgmac_pdata *pdata) in xlgmac_config_mac_speed() argument
2619 switch (pdata->phy_speed) { in xlgmac_config_mac_speed()
2621 xlgmac_set_xlgmii_100000_speed(pdata); in xlgmac_config_mac_speed()
2625 xlgmac_set_xlgmii_50000_speed(pdata); in xlgmac_config_mac_speed()
2629 xlgmac_set_xlgmii_40000_speed(pdata); in xlgmac_config_mac_speed()
2633 xlgmac_set_xlgmii_25000_speed(pdata); in xlgmac_config_mac_speed()
2640 struct xlgmac_pdata *pdata = channel->pdata; in xlgmac_dev_read() local
2642 struct net_device *netdev = pdata->netdev; in xlgmac_dev_read()
2661 if (netif_msg_rx_status(pdata)) in xlgmac_dev_read()
2662 xlgmac_dump_rx_desc(pdata, ring, ring->cur); in xlgmac_dev_read()
2708 pdata->stats.rx_split_header_packets++; in xlgmac_dev_read()
2777 netif_dbg(pdata, rx_status, netdev, "err=%u, etlt=%#x\n", err, etlt); in xlgmac_dev_read()
2792 netif_dbg(pdata, rx_status, netdev, "vlan-ctag=%#06x\n", in xlgmac_dev_read()
2943 static int xlgmac_flush_tx_queues(struct xlgmac_pdata *pdata) in xlgmac_flush_tx_queues() argument
2948 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_flush_tx_queues()
2949 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_flush_tx_queues()
2952 writel(regval, XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_flush_tx_queues()
2956 for (i = 0; i < pdata->tx_q_count; i++) { in xlgmac_flush_tx_queues()
2958 regval = readl(XLGMAC_MTL_REG(pdata, i, MTL_Q_TQOMR)); in xlgmac_flush_tx_queues()
2971 static void xlgmac_config_dma_bus(struct xlgmac_pdata *pdata) in xlgmac_config_dma_bus() argument
2975 regval = readl(pdata->mac_regs + DMA_SBMR); in xlgmac_config_dma_bus()
2984 writel(regval, pdata->mac_regs + DMA_SBMR); in xlgmac_config_dma_bus()
2987 static int xlgmac_hw_init(struct xlgmac_pdata *pdata) in xlgmac_hw_init() argument
2989 struct xlgmac_desc_ops *desc_ops = &pdata->desc_ops; in xlgmac_hw_init()
2993 ret = xlgmac_flush_tx_queues(pdata); in xlgmac_hw_init()
2998 xlgmac_config_dma_bus(pdata); in xlgmac_hw_init()
2999 xlgmac_config_osp_mode(pdata); in xlgmac_hw_init()
3000 xlgmac_config_pblx8(pdata); in xlgmac_hw_init()
3001 xlgmac_config_tx_pbl_val(pdata); in xlgmac_hw_init()
3002 xlgmac_config_rx_pbl_val(pdata); in xlgmac_hw_init()
3003 xlgmac_config_rx_coalesce(pdata); in xlgmac_hw_init()
3004 xlgmac_config_tx_coalesce(pdata); in xlgmac_hw_init()
3005 xlgmac_config_rx_buffer_size(pdata); in xlgmac_hw_init()
3006 xlgmac_config_tso_mode(pdata); in xlgmac_hw_init()
3007 xlgmac_config_sph_mode(pdata); in xlgmac_hw_init()
3008 xlgmac_config_rss(pdata); in xlgmac_hw_init()
3009 desc_ops->tx_desc_init(pdata); in xlgmac_hw_init()
3010 desc_ops->rx_desc_init(pdata); in xlgmac_hw_init()
3011 xlgmac_enable_dma_interrupts(pdata); in xlgmac_hw_init()
3014 xlgmac_config_mtl_mode(pdata); in xlgmac_hw_init()
3015 xlgmac_config_queue_mapping(pdata); in xlgmac_hw_init()
3016 xlgmac_config_tsf_mode(pdata, pdata->tx_sf_mode); in xlgmac_hw_init()
3017 xlgmac_config_rsf_mode(pdata, pdata->rx_sf_mode); in xlgmac_hw_init()
3018 xlgmac_config_tx_threshold(pdata, pdata->tx_threshold); in xlgmac_hw_init()
3019 xlgmac_config_rx_threshold(pdata, pdata->rx_threshold); in xlgmac_hw_init()
3020 xlgmac_config_tx_fifo_size(pdata); in xlgmac_hw_init()
3021 xlgmac_config_rx_fifo_size(pdata); in xlgmac_hw_init()
3022 xlgmac_config_flow_control_threshold(pdata); in xlgmac_hw_init()
3023 xlgmac_config_rx_fep_enable(pdata); in xlgmac_hw_init()
3024 xlgmac_config_rx_fup_enable(pdata); in xlgmac_hw_init()
3025 xlgmac_enable_mtl_interrupts(pdata); in xlgmac_hw_init()
3028 xlgmac_config_mac_address(pdata); in xlgmac_hw_init()
3029 xlgmac_config_rx_mode(pdata); in xlgmac_hw_init()
3030 xlgmac_config_jumbo_enable(pdata); in xlgmac_hw_init()
3031 xlgmac_config_flow_control(pdata); in xlgmac_hw_init()
3032 xlgmac_config_mac_speed(pdata); in xlgmac_hw_init()
3033 xlgmac_config_checksum_offload(pdata); in xlgmac_hw_init()
3034 xlgmac_config_vlan_support(pdata); in xlgmac_hw_init()
3035 xlgmac_config_mmc(pdata); in xlgmac_hw_init()
3036 xlgmac_enable_mac_interrupts(pdata); in xlgmac_hw_init()
3041 static int xlgmac_hw_exit(struct xlgmac_pdata *pdata) in xlgmac_hw_exit() argument
3047 regval = readl(pdata->mac_regs + DMA_MR); in xlgmac_hw_exit()
3050 writel(regval, pdata->mac_regs + DMA_MR); in xlgmac_hw_exit()
3055 XLGMAC_GET_REG_BITS(readl(pdata->mac_regs + DMA_MR), in xlgmac_hw_exit()