Lines Matching +full:1588 +full:- +full:2008
5 * This program is dual-licensed; you may select either version 2 of
21 #include "dwc-xlgmac.h"
22 #include "dwc-xlgmac-reg.h"
26 static int debug = -1;
36 struct net_device *netdev = pdata->netdev; in xlgmac_read_mac_addr()
39 memcpy(pdata->mac_addr, dev_addr, netdev->addr_len); in xlgmac_read_mac_addr()
44 pdata->tx_osp_mode = DMA_OSP_ENABLE; in xlgmac_default_config()
45 pdata->tx_sf_mode = MTL_TSF_ENABLE; in xlgmac_default_config()
46 pdata->rx_sf_mode = MTL_RSF_DISABLE; in xlgmac_default_config()
47 pdata->pblx8 = DMA_PBL_X8_ENABLE; in xlgmac_default_config()
48 pdata->tx_pbl = DMA_PBL_32; in xlgmac_default_config()
49 pdata->rx_pbl = DMA_PBL_32; in xlgmac_default_config()
50 pdata->tx_threshold = MTL_TX_THRESHOLD_128; in xlgmac_default_config()
51 pdata->rx_threshold = MTL_RX_THRESHOLD_128; in xlgmac_default_config()
52 pdata->tx_pause = 1; in xlgmac_default_config()
53 pdata->rx_pause = 1; in xlgmac_default_config()
54 pdata->phy_speed = SPEED_25000; in xlgmac_default_config()
55 pdata->sysclk_rate = XLGMAC_SYSCLOCK; in xlgmac_default_config()
57 strlcpy(pdata->drv_name, XLGMAC_DRV_NAME, sizeof(pdata->drv_name)); in xlgmac_default_config()
58 strlcpy(pdata->drv_ver, XLGMAC_DRV_VERSION, sizeof(pdata->drv_ver)); in xlgmac_default_config()
63 xlgmac_init_desc_ops(&pdata->desc_ops); in xlgmac_init_all_ops()
64 xlgmac_init_hw_ops(&pdata->hw_ops); in xlgmac_init_all_ops()
69 struct xlgmac_hw_ops *hw_ops = &pdata->hw_ops; in xlgmac_init()
70 struct net_device *netdev = pdata->netdev; in xlgmac_init()
78 netdev->irq = pdata->dev_irq; in xlgmac_init()
79 netdev->base_addr = (unsigned long)pdata->mac_regs; in xlgmac_init()
81 memcpy(netdev->dev_addr, pdata->mac_addr, netdev->addr_len); in xlgmac_init()
87 hw_ops->exit(pdata); in xlgmac_init()
96 ret = dma_set_mask_and_coherent(pdata->dev, in xlgmac_init()
97 DMA_BIT_MASK(pdata->hw_feat.dma_width)); in xlgmac_init()
99 dev_err(pdata->dev, "dma_set_mask_and_coherent failed\n"); in xlgmac_init()
104 * pdata->channel_count; in xlgmac_init()
105 * pdata->tx_ring_count; in xlgmac_init()
106 * pdata->rx_ring_count; in xlgmac_init()
107 * pdata->tx_desc_count; in xlgmac_init()
108 * pdata->rx_desc_count; in xlgmac_init()
111 pdata->tx_desc_count = XLGMAC_TX_DESC_CNT; in xlgmac_init()
112 if (pdata->tx_desc_count & (pdata->tx_desc_count - 1)) { in xlgmac_init()
113 dev_err(pdata->dev, "tx descriptor count (%d) is not valid\n", in xlgmac_init()
114 pdata->tx_desc_count); in xlgmac_init()
115 ret = -EINVAL; in xlgmac_init()
119 pdata->rx_desc_count = XLGMAC_RX_DESC_CNT; in xlgmac_init()
120 if (pdata->rx_desc_count & (pdata->rx_desc_count - 1)) { in xlgmac_init()
121 dev_err(pdata->dev, "rx descriptor count (%d) is not valid\n", in xlgmac_init()
122 pdata->rx_desc_count); in xlgmac_init()
123 ret = -EINVAL; in xlgmac_init()
127 pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(), in xlgmac_init()
128 pdata->hw_feat.tx_ch_cnt); in xlgmac_init()
129 pdata->tx_ring_count = min_t(unsigned int, pdata->tx_ring_count, in xlgmac_init()
130 pdata->hw_feat.tx_q_cnt); in xlgmac_init()
131 pdata->tx_q_count = pdata->tx_ring_count; in xlgmac_init()
132 ret = netif_set_real_num_tx_queues(netdev, pdata->tx_q_count); in xlgmac_init()
134 dev_err(pdata->dev, "error setting real tx queue count\n"); in xlgmac_init()
138 pdata->rx_ring_count = min_t(unsigned int, in xlgmac_init()
140 pdata->hw_feat.rx_ch_cnt); in xlgmac_init()
141 pdata->rx_ring_count = min_t(unsigned int, pdata->rx_ring_count, in xlgmac_init()
142 pdata->hw_feat.rx_q_cnt); in xlgmac_init()
143 pdata->rx_q_count = pdata->rx_ring_count; in xlgmac_init()
144 ret = netif_set_real_num_rx_queues(netdev, pdata->rx_q_count); in xlgmac_init()
146 dev_err(pdata->dev, "error setting real rx queue count\n"); in xlgmac_init()
150 pdata->channel_count = in xlgmac_init()
151 max_t(unsigned int, pdata->tx_ring_count, pdata->rx_ring_count); in xlgmac_init()
154 netdev_rss_key_fill(pdata->rss_key, sizeof(pdata->rss_key)); in xlgmac_init()
157 pdata->rss_table[i] = XLGMAC_SET_REG_BITS( in xlgmac_init()
158 pdata->rss_table[i], in xlgmac_init()
161 i % pdata->rx_ring_count); in xlgmac_init()
163 pdata->rss_options = XLGMAC_SET_REG_BITS( in xlgmac_init()
164 pdata->rss_options, in xlgmac_init()
167 pdata->rss_options = XLGMAC_SET_REG_BITS( in xlgmac_init()
168 pdata->rss_options, in xlgmac_init()
171 pdata->rss_options = XLGMAC_SET_REG_BITS( in xlgmac_init()
172 pdata->rss_options, in xlgmac_init()
177 netdev->netdev_ops = xlgmac_get_netdev_ops(); in xlgmac_init()
178 netdev->ethtool_ops = xlgmac_get_ethtool_ops(); in xlgmac_init()
181 if (pdata->hw_feat.tso) { in xlgmac_init()
182 netdev->hw_features = NETIF_F_TSO; in xlgmac_init()
183 netdev->hw_features |= NETIF_F_TSO6; in xlgmac_init()
184 netdev->hw_features |= NETIF_F_SG; in xlgmac_init()
185 netdev->hw_features |= NETIF_F_IP_CSUM; in xlgmac_init()
186 netdev->hw_features |= NETIF_F_IPV6_CSUM; in xlgmac_init()
187 } else if (pdata->hw_feat.tx_coe) { in xlgmac_init()
188 netdev->hw_features = NETIF_F_IP_CSUM; in xlgmac_init()
189 netdev->hw_features |= NETIF_F_IPV6_CSUM; in xlgmac_init()
192 if (pdata->hw_feat.rx_coe) { in xlgmac_init()
193 netdev->hw_features |= NETIF_F_RXCSUM; in xlgmac_init()
194 netdev->hw_features |= NETIF_F_GRO; in xlgmac_init()
197 if (pdata->hw_feat.rss) in xlgmac_init()
198 netdev->hw_features |= NETIF_F_RXHASH; in xlgmac_init()
200 netdev->vlan_features |= netdev->hw_features; in xlgmac_init()
202 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_RX; in xlgmac_init()
203 if (pdata->hw_feat.sa_vlan_ins) in xlgmac_init()
204 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_TX; in xlgmac_init()
205 if (pdata->hw_feat.vlhash) in xlgmac_init()
206 netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; in xlgmac_init()
208 netdev->features |= netdev->hw_features; in xlgmac_init()
209 pdata->netdev_features = netdev->features; in xlgmac_init()
211 netdev->priv_flags |= IFF_UNICAST_FLT; in xlgmac_init()
214 netdev->watchdog_timeo = 0; in xlgmac_init()
217 pdata->tx_usecs = XLGMAC_INIT_DMA_TX_USECS; in xlgmac_init()
218 pdata->tx_frames = XLGMAC_INIT_DMA_TX_FRAMES; in xlgmac_init()
221 pdata->rx_riwt = hw_ops->usec_to_riwt(pdata, XLGMAC_INIT_DMA_RX_USECS); in xlgmac_init()
222 pdata->rx_usecs = XLGMAC_INIT_DMA_RX_USECS; in xlgmac_init()
223 pdata->rx_frames = XLGMAC_INIT_DMA_RX_FRAMES; in xlgmac_init()
239 return -ENOMEM; in xlgmac_drv_probe()
245 pdata->dev = dev; in xlgmac_drv_probe()
246 pdata->netdev = netdev; in xlgmac_drv_probe()
248 pdata->dev_irq = res->irq; in xlgmac_drv_probe()
249 pdata->mac_regs = res->addr; in xlgmac_drv_probe()
251 mutex_init(&pdata->rss_mutex); in xlgmac_drv_probe()
252 pdata->msg_enable = netif_msg_init(debug, default_msg_level); in xlgmac_drv_probe()
293 while (count--) { in xlgmac_dump_tx_desc()
295 dma_desc = desc_data->dma_desc; in xlgmac_dump_tx_desc()
297 netdev_dbg(pdata->netdev, "TX: dma_desc=%p, dma_desc_addr=%pad\n", in xlgmac_dump_tx_desc()
298 desc_data->dma_desc, &desc_data->dma_desc_addr); in xlgmac_dump_tx_desc()
299 netdev_dbg(pdata->netdev, in xlgmac_dump_tx_desc()
302 le32_to_cpu(dma_desc->desc0), in xlgmac_dump_tx_desc()
303 le32_to_cpu(dma_desc->desc1), in xlgmac_dump_tx_desc()
304 le32_to_cpu(dma_desc->desc2), in xlgmac_dump_tx_desc()
305 le32_to_cpu(dma_desc->desc3)); in xlgmac_dump_tx_desc()
319 dma_desc = desc_data->dma_desc; in xlgmac_dump_rx_desc()
321 netdev_dbg(pdata->netdev, "RX: dma_desc=%p, dma_desc_addr=%pad\n", in xlgmac_dump_rx_desc()
322 desc_data->dma_desc, &desc_data->dma_desc_addr); in xlgmac_dump_rx_desc()
323 netdev_dbg(pdata->netdev, in xlgmac_dump_rx_desc()
326 le32_to_cpu(dma_desc->desc0), in xlgmac_dump_rx_desc()
327 le32_to_cpu(dma_desc->desc1), in xlgmac_dump_rx_desc()
328 le32_to_cpu(dma_desc->desc2), in xlgmac_dump_rx_desc()
329 le32_to_cpu(dma_desc->desc3)); in xlgmac_dump_rx_desc()
335 struct ethhdr *eth = (struct ethhdr *)skb->data; in xlgmac_print_pkt()
342 (tx_rx ? "TX" : "RX"), skb->len); in xlgmac_print_pkt()
344 netdev_dbg(netdev, "Dst MAC addr: %pM\n", eth->h_dest); in xlgmac_print_pkt()
345 netdev_dbg(netdev, "Src MAC addr: %pM\n", eth->h_source); in xlgmac_print_pkt()
346 netdev_dbg(netdev, "Protocol: %#06hx\n", ntohs(eth->h_proto)); in xlgmac_print_pkt()
348 for (i = 0; i < skb->len; i += 32) { in xlgmac_print_pkt()
349 unsigned int len = min(skb->len - i, 32U); in xlgmac_print_pkt()
351 hex_dump_to_buffer(&skb->data[i], len, 32, 1, in xlgmac_print_pkt()
361 struct xlgmac_hw_features *hw_feat = &pdata->hw_feat; in xlgmac_get_all_hw_features()
364 mac_hfr0 = readl(pdata->mac_regs + MAC_HWF0R); in xlgmac_get_all_hw_features()
365 mac_hfr1 = readl(pdata->mac_regs + MAC_HWF1R); in xlgmac_get_all_hw_features()
366 mac_hfr2 = readl(pdata->mac_regs + MAC_HWF2R); in xlgmac_get_all_hw_features()
370 hw_feat->version = readl(pdata->mac_regs + MAC_VR); in xlgmac_get_all_hw_features()
373 hw_feat->phyifsel = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
376 hw_feat->vlhash = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
379 hw_feat->sma = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
382 hw_feat->rwk = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
385 hw_feat->mgk = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
388 hw_feat->mmc = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
391 hw_feat->aoe = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
394 hw_feat->ts = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
397 hw_feat->eee = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
400 hw_feat->tx_coe = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
403 hw_feat->rx_coe = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
406 hw_feat->addn_mac = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
409 hw_feat->ts_src = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
412 hw_feat->sa_vlan_ins = XLGMAC_GET_REG_BITS(mac_hfr0, in xlgmac_get_all_hw_features()
417 hw_feat->rx_fifo_size = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
420 hw_feat->tx_fifo_size = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
423 hw_feat->adv_ts_hi = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
426 hw_feat->dma_width = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
429 hw_feat->dcb = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
432 hw_feat->sph = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
435 hw_feat->tso = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
438 hw_feat->dma_debug = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
441 hw_feat->rss = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
444 hw_feat->tc_cnt = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
447 hw_feat->hash_table_size = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
450 hw_feat->l3l4_filter_num = XLGMAC_GET_REG_BITS(mac_hfr1, in xlgmac_get_all_hw_features()
455 hw_feat->rx_q_cnt = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
458 hw_feat->tx_q_cnt = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
461 hw_feat->rx_ch_cnt = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
464 hw_feat->tx_ch_cnt = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
467 hw_feat->pps_out_num = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
470 hw_feat->aux_snap_num = XLGMAC_GET_REG_BITS(mac_hfr2, in xlgmac_get_all_hw_features()
475 switch (hw_feat->hash_table_size) { in xlgmac_get_all_hw_features()
479 hw_feat->hash_table_size = 64; in xlgmac_get_all_hw_features()
482 hw_feat->hash_table_size = 128; in xlgmac_get_all_hw_features()
485 hw_feat->hash_table_size = 256; in xlgmac_get_all_hw_features()
490 switch (hw_feat->dma_width) { in xlgmac_get_all_hw_features()
492 hw_feat->dma_width = 32; in xlgmac_get_all_hw_features()
495 hw_feat->dma_width = 40; in xlgmac_get_all_hw_features()
498 hw_feat->dma_width = 48; in xlgmac_get_all_hw_features()
501 hw_feat->dma_width = 32; in xlgmac_get_all_hw_features()
507 hw_feat->rx_q_cnt++; in xlgmac_get_all_hw_features()
508 hw_feat->tx_q_cnt++; in xlgmac_get_all_hw_features()
509 hw_feat->rx_ch_cnt++; in xlgmac_get_all_hw_features()
510 hw_feat->tx_ch_cnt++; in xlgmac_get_all_hw_features()
511 hw_feat->tc_cnt++; in xlgmac_get_all_hw_features()
525 pdata->hw_feat.vlhash ? "YES" : "NO"); in xlgmac_print_all_hw_features()
527 pdata->hw_feat.sma ? "YES" : "NO"); in xlgmac_print_all_hw_features()
528 XLGMAC_PR("PMT Remote Wake-up Packet Enable : %s\n", in xlgmac_print_all_hw_features()
529 pdata->hw_feat.rwk ? "YES" : "NO"); in xlgmac_print_all_hw_features()
531 pdata->hw_feat.mgk ? "YES" : "NO"); in xlgmac_print_all_hw_features()
533 pdata->hw_feat.mmc ? "YES" : "NO"); in xlgmac_print_all_hw_features()
535 pdata->hw_feat.aoe ? "YES" : "NO"); in xlgmac_print_all_hw_features()
536 XLGMAC_PR("IEEE 1588-2008 Timestamp Enabled : %s\n", in xlgmac_print_all_hw_features()
537 pdata->hw_feat.ts ? "YES" : "NO"); in xlgmac_print_all_hw_features()
539 pdata->hw_feat.eee ? "YES" : "NO"); in xlgmac_print_all_hw_features()
541 pdata->hw_feat.tx_coe ? "YES" : "NO"); in xlgmac_print_all_hw_features()
543 pdata->hw_feat.rx_coe ? "YES" : "NO"); in xlgmac_print_all_hw_features()
544 XLGMAC_PR("Additional MAC Addresses 1-31 Selected : %s\n", in xlgmac_print_all_hw_features()
545 pdata->hw_feat.addn_mac ? "YES" : "NO"); in xlgmac_print_all_hw_features()
547 switch (pdata->hw_feat.ts_src) { in xlgmac_print_all_hw_features()
564 pdata->hw_feat.sa_vlan_ins ? "YES" : "NO"); in xlgmac_print_all_hw_features()
567 switch (pdata->hw_feat.rx_fifo_size) { in xlgmac_print_all_hw_features()
609 switch (pdata->hw_feat.tx_fifo_size) { in xlgmac_print_all_hw_features()
651 XLGMAC_PR("IEEE 1588 High Word Register Enable : %s\n", in xlgmac_print_all_hw_features()
652 pdata->hw_feat.adv_ts_hi ? "YES" : "NO"); in xlgmac_print_all_hw_features()
654 pdata->hw_feat.dma_width); in xlgmac_print_all_hw_features()
656 pdata->hw_feat.dcb ? "YES" : "NO"); in xlgmac_print_all_hw_features()
658 pdata->hw_feat.sph ? "YES" : "NO"); in xlgmac_print_all_hw_features()
660 pdata->hw_feat.tso ? "YES" : "NO"); in xlgmac_print_all_hw_features()
662 pdata->hw_feat.dma_debug ? "YES" : "NO"); in xlgmac_print_all_hw_features()
664 pdata->hw_feat.rss ? "YES" : "NO"); in xlgmac_print_all_hw_features()
666 (pdata->hw_feat.tc_cnt)); in xlgmac_print_all_hw_features()
668 pdata->hw_feat.hash_table_size); in xlgmac_print_all_hw_features()
670 pdata->hw_feat.l3l4_filter_num); in xlgmac_print_all_hw_features()
674 pdata->hw_feat.rx_q_cnt); in xlgmac_print_all_hw_features()
676 pdata->hw_feat.tx_q_cnt); in xlgmac_print_all_hw_features()
678 pdata->hw_feat.rx_ch_cnt); in xlgmac_print_all_hw_features()
680 pdata->hw_feat.tx_ch_cnt); in xlgmac_print_all_hw_features()
682 switch (pdata->hw_feat.pps_out_num) { in xlgmac_print_all_hw_features()
703 switch (pdata->hw_feat.aux_snap_num) { in xlgmac_print_all_hw_features()