Lines Matching +full:iommu +full:- +full:v1
1 // SPDX-License-Identifier: GPL-2.0-or-later
31 #include <linux/dma-mapping.h>
63 card->irq_mask |= GELIC_CARD_RXINT; in gelic_card_rx_irq_on()
64 gelic_card_set_irq_mask(card, card->irq_mask); in gelic_card_rx_irq_on()
68 card->irq_mask &= ~GELIC_CARD_RXINT; in gelic_card_rx_irq_off()
69 gelic_card_set_irq_mask(card, card->irq_mask); in gelic_card_rx_irq_off()
81 &card->ether_port_status, &v2); in gelic_card_get_ether_port_status()
84 ether_netdev = card->netdev[GELIC_PORT_ETHERNET_0]; in gelic_card_get_ether_port_status()
85 if (card->ether_port_status & GELIC_LV1_ETHER_LINK_UP) in gelic_card_get_ether_port_status()
93 * gelic_descr_get_status -- returns the status of a descriptor
101 return be32_to_cpu(descr->hw_regs.dmac_cmd_status) & in gelic_descr_get_status()
108 u64 v1, v2; in gelic_card_set_link_mode() local
112 GELIC_LV1_PHY_ETHERNET_0, mode, 0, &v1, &v2); in gelic_card_set_link_mode()
116 return -EBUSY; in gelic_card_set_link_mode()
119 card->link_mode = mode; in gelic_card_set_link_mode()
124 * gelic_card_disable_txdmac - disables the transmit DMA controller
142 * gelic_card_enable_rxdmac - enables the receive DMA controller
153 if (gelic_descr_get_status(card->rx_chain.head) != in gelic_card_enable_rxdmac()
156 be32_to_cpu(card->rx_chain.head->hw_regs.dmac_cmd_status)); in gelic_card_enable_rxdmac()
158 be32_to_cpu(card->rx_chain.head->hw_regs.next_descr_addr)); in gelic_card_enable_rxdmac()
160 card->rx_chain.head); in gelic_card_enable_rxdmac()
164 card->rx_chain.head->link.cpu_addr, 0); in gelic_card_enable_rxdmac()
171 * gelic_card_disable_rxdmac - disables the receive DMA controller
189 * gelic_descr_set_status -- sets the status of a descriptor
199 descr->hw_regs.dmac_cmd_status = cpu_to_be32(status | in gelic_descr_set_status()
200 (be32_to_cpu(descr->hw_regs.dmac_cmd_status) & in gelic_descr_set_status()
212 * gelic_card_reset_chain - reset status of a descriptor chain
218 * and re-initialize the hardware chain for later use
226 for (descr = start_descr; start_descr != descr->next; descr++) { in gelic_card_reset_chain()
228 descr->hw_regs.next_descr_addr in gelic_card_reset_chain()
229 = cpu_to_be32(descr->next->link.cpu_addr); in gelic_card_reset_chain()
232 chain->head = start_descr; in gelic_card_reset_chain()
233 chain->tail = (descr - 1); in gelic_card_reset_chain()
235 (descr - 1)->hw_regs.next_descr_addr = 0; in gelic_card_reset_chain()
241 mutex_lock(&card->updown_lock); in gelic_card_up()
242 if (atomic_inc_return(&card->users) == 1) { in gelic_card_up()
245 gelic_card_set_irq_mask(card, card->irq_mask); in gelic_card_up()
249 napi_enable(&card->napi); in gelic_card_up()
251 mutex_unlock(&card->updown_lock); in gelic_card_up()
259 mutex_lock(&card->updown_lock); in gelic_card_down()
260 if (atomic_dec_if_positive(&card->users) == 0) { in gelic_card_down()
262 napi_disable(&card->napi); in gelic_card_down()
267 mask = card->irq_mask & (GELIC_CARD_WLAN_EVENT_RECEIVED | in gelic_card_down()
272 gelic_card_reset_chain(card, &card->rx_chain, in gelic_card_down()
273 card->descr + GELIC_NET_TX_DESCRIPTORS); in gelic_card_down()
277 mutex_unlock(&card->updown_lock); in gelic_card_down()
282 * gelic_card_free_chain - free descriptor chain
291 for (descr = descr_in; descr && descr->link.cpu_addr; in gelic_card_free_chain()
292 descr = descr->next) { in gelic_card_free_chain()
293 dma_unmap_single(ctodev(card), descr->link.cpu_addr, in gelic_card_free_chain()
294 descr->link.size, DMA_BIDIRECTIONAL); in gelic_card_free_chain()
295 descr->link.cpu_addr = 0; in gelic_card_free_chain()
296 descr->link.size = 0; in gelic_card_free_chain()
301 * gelic_card_init_chain - links descriptor chain
326 descr->link.size = sizeof(struct gelic_hw_regs); in gelic_card_init_chain()
327 descr->link.cpu_addr = dma_map_single(ctodev(card), descr, in gelic_card_init_chain()
328 descr->link.size, DMA_BIDIRECTIONAL); in gelic_card_init_chain()
330 if (dma_mapping_error(ctodev(card), descr->link.cpu_addr)) { in gelic_card_init_chain()
331 for (i--, descr--; 0 <= i; i--, descr--) { in gelic_card_init_chain()
333 descr->link.cpu_addr, descr->link.size, in gelic_card_init_chain()
336 return -ENOMEM; in gelic_card_init_chain()
339 descr->next = descr + 1; in gelic_card_init_chain()
340 descr->prev = descr - 1; in gelic_card_init_chain()
343 (descr - 1)->next = start_descr; in gelic_card_init_chain()
344 start_descr->prev = (descr - 1); in gelic_card_init_chain()
349 descr->hw_regs.next_descr_addr = in gelic_card_init_chain()
350 cpu_to_be32(descr->next->link.cpu_addr); in gelic_card_init_chain()
353 chain->head = start_descr; in gelic_card_init_chain()
354 chain->tail = start_descr; in gelic_card_init_chain()
357 (descr - 1)->hw_regs.next_descr_addr = 0; in gelic_card_init_chain()
363 * gelic_descr_prepare_rx - reinitializes a rx descriptor
365 * @descr: descriptor to re-init
369 * allocates a new rx skb, iommu-maps it and attaches it to the descriptor.
370 * Activate the descriptor state-wise
380 GELIC_NET_RXBUF_ALIGN - 1; in gelic_descr_prepare_rx()
387 descr->hw_regs.dmac_cmd_status = 0; in gelic_descr_prepare_rx()
388 descr->hw_regs.result_size = 0; in gelic_descr_prepare_rx()
389 descr->hw_regs.valid_size = 0; in gelic_descr_prepare_rx()
390 descr->hw_regs.data_error = 0; in gelic_descr_prepare_rx()
391 descr->hw_regs.payload.dev_addr = 0; in gelic_descr_prepare_rx()
392 descr->hw_regs.payload.size = 0; in gelic_descr_prepare_rx()
394 descr->skb = netdev_alloc_skb(*card->netdev, rx_skb_size); in gelic_descr_prepare_rx()
395 if (!descr->skb) { in gelic_descr_prepare_rx()
396 descr->hw_regs.payload.dev_addr = 0; /* tell DMAC don't touch memory */ in gelic_descr_prepare_rx()
397 return -ENOMEM; in gelic_descr_prepare_rx()
400 offset = ((unsigned long)descr->skb->data) & in gelic_descr_prepare_rx()
401 (GELIC_NET_RXBUF_ALIGN - 1); in gelic_descr_prepare_rx()
403 skb_reserve(descr->skb, GELIC_NET_RXBUF_ALIGN - offset); in gelic_descr_prepare_rx()
404 /* io-mmu-map the skb */ in gelic_descr_prepare_rx()
405 cpu_addr = dma_map_single(ctodev(card), descr->skb->data, in gelic_descr_prepare_rx()
407 descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr); in gelic_descr_prepare_rx()
409 dev_kfree_skb_any(descr->skb); in gelic_descr_prepare_rx()
410 descr->skb = NULL; in gelic_descr_prepare_rx()
412 "%s:Could not iommu-map rx buffer\n", __func__); in gelic_descr_prepare_rx()
414 return -ENOMEM; in gelic_descr_prepare_rx()
417 descr->hw_regs.payload.size = cpu_to_be32(GELIC_NET_MAX_FRAME); in gelic_descr_prepare_rx()
418 descr->hw_regs.payload.dev_addr = cpu_to_be32(cpu_addr); in gelic_descr_prepare_rx()
426 * gelic_card_release_rx_chain - free all skb of rx descr
432 struct gelic_descr *descr = card->rx_chain.head; in gelic_card_release_rx_chain()
435 if (descr->skb) { in gelic_card_release_rx_chain()
437 be32_to_cpu(descr->hw_regs.payload.dev_addr), in gelic_card_release_rx_chain()
438 descr->skb->len, in gelic_card_release_rx_chain()
440 descr->hw_regs.payload.dev_addr = 0; in gelic_card_release_rx_chain()
441 descr->hw_regs.payload.size = 0; in gelic_card_release_rx_chain()
442 dev_kfree_skb_any(descr->skb); in gelic_card_release_rx_chain()
443 descr->skb = NULL; in gelic_card_release_rx_chain()
447 descr = descr->next; in gelic_card_release_rx_chain()
448 } while (descr != card->rx_chain.head); in gelic_card_release_rx_chain()
452 * gelic_card_fill_rx_chain - fills descriptors/skbs in the rx chains
456 * and iommu-maps them.
461 struct gelic_descr *descr = card->rx_chain.head; in gelic_card_fill_rx_chain()
465 if (!descr->skb) { in gelic_card_fill_rx_chain()
470 descr = descr->next; in gelic_card_fill_rx_chain()
471 } while (descr != card->rx_chain.head); in gelic_card_fill_rx_chain()
480 * gelic_card_alloc_rx_skbs - allocates rx skbs in rx descriptor chains
489 chain = &card->rx_chain; in gelic_card_alloc_rx_skbs()
491 chain->tail = card->rx_top->prev; /* point to the last */ in gelic_card_alloc_rx_skbs()
496 * gelic_descr_release_tx - processes a used tx descriptor
505 struct sk_buff *skb = descr->skb; in gelic_descr_release_tx()
507 BUG_ON(!(be32_to_cpu(descr->hw_regs.data_status) & GELIC_DESCR_TX_TAIL)); in gelic_descr_release_tx()
510 be32_to_cpu(descr->hw_regs.payload.dev_addr), skb->len, in gelic_descr_release_tx()
514 descr->hw_regs.payload.dev_addr = 0; in gelic_descr_release_tx()
515 descr->hw_regs.payload.size = 0; in gelic_descr_release_tx()
516 descr->hw_regs.next_descr_addr = 0; in gelic_descr_release_tx()
517 descr->hw_regs.result_size = 0; in gelic_descr_release_tx()
518 descr->hw_regs.valid_size = 0; in gelic_descr_release_tx()
519 descr->hw_regs.data_status = 0; in gelic_descr_release_tx()
520 descr->hw_regs.data_error = 0; in gelic_descr_release_tx()
521 descr->skb = NULL; in gelic_descr_release_tx()
529 netif_stop_queue(card->netdev[GELIC_PORT_ETHERNET_0]); in gelic_card_stop_queues()
531 if (card->netdev[GELIC_PORT_WIRELESS]) in gelic_card_stop_queues()
532 netif_stop_queue(card->netdev[GELIC_PORT_WIRELESS]); in gelic_card_stop_queues()
536 netif_wake_queue(card->netdev[GELIC_PORT_ETHERNET_0]); in gelic_card_wake_queues()
538 if (card->netdev[GELIC_PORT_WIRELESS]) in gelic_card_wake_queues()
539 netif_wake_queue(card->netdev[GELIC_PORT_WIRELESS]); in gelic_card_wake_queues()
542 * gelic_card_release_tx_chain - processes sent tx descriptors
555 for (tx_chain = &card->tx_chain; in gelic_card_release_tx_chain()
556 tx_chain->head != tx_chain->tail && tx_chain->tail; in gelic_card_release_tx_chain()
557 tx_chain->tail = tx_chain->tail->next) { in gelic_card_release_tx_chain()
558 status = gelic_descr_get_status(tx_chain->tail); in gelic_card_release_tx_chain()
559 netdev = tx_chain->tail->skb->dev; in gelic_card_release_tx_chain()
569 netdev->stats.tx_dropped++; in gelic_card_release_tx_chain()
573 if (tx_chain->tail->skb) { in gelic_card_release_tx_chain()
574 netdev->stats.tx_packets++; in gelic_card_release_tx_chain()
575 netdev->stats.tx_bytes += in gelic_card_release_tx_chain()
576 tx_chain->tail->skb->len; in gelic_card_release_tx_chain()
587 gelic_descr_release_tx(card, tx_chain->tail); in gelic_card_release_tx_chain()
596 * gelic_net_set_multi - sets multicast addresses and promisc flags
627 if ((netdev->flags & IFF_ALLMULTI) || in gelic_net_set_multi()
642 p = ha->addr; in gelic_net_set_multi()
658 * gelic_net_stop - called upon ifconfig down
680 * gelic_card_get_next_tx_descr - returns the next available tx descriptor
688 if (!card->tx_chain.head) in gelic_card_get_next_tx_descr()
691 if (card->tx_chain.tail != card->tx_chain.head->next && in gelic_card_get_next_tx_descr()
692 gelic_descr_get_status(card->tx_chain.head) == in gelic_card_get_next_tx_descr()
694 return card->tx_chain.head; in gelic_card_get_next_tx_descr()
701 * gelic_descr_set_tx_cmdstat - sets the tx descriptor command field
712 if (skb->ip_summed != CHECKSUM_PARTIAL) in gelic_descr_set_tx_cmdstat()
713 descr->hw_regs.dmac_cmd_status = in gelic_descr_set_tx_cmdstat()
719 if (skb->protocol == htons(ETH_P_IP)) { in gelic_descr_set_tx_cmdstat()
720 if (ip_hdr(skb)->protocol == IPPROTO_TCP) in gelic_descr_set_tx_cmdstat()
721 descr->hw_regs.dmac_cmd_status = in gelic_descr_set_tx_cmdstat()
725 else if (ip_hdr(skb)->protocol == IPPROTO_UDP) in gelic_descr_set_tx_cmdstat()
726 descr->hw_regs.dmac_cmd_status = in gelic_descr_set_tx_cmdstat()
730 * the stack should checksum non-tcp and non-udp in gelic_descr_set_tx_cmdstat()
733 descr->hw_regs.dmac_cmd_status = in gelic_descr_set_tx_cmdstat()
757 memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN); in gelic_put_vlan_tag()
759 veth->h_vlan_proto = cpu_to_be16(ETH_P_8021Q); in gelic_put_vlan_tag()
760 veth->h_vlan_TCI = htons(tag); in gelic_put_vlan_tag()
766 * gelic_descr_prepare_tx - setup a descriptor for sending packets
780 if (card->vlan_required) { in gelic_descr_prepare_tx()
784 type = netdev_port(skb->dev)->type; in gelic_descr_prepare_tx()
786 card->vlan[type].tx); in gelic_descr_prepare_tx()
788 return -ENOMEM; in gelic_descr_prepare_tx()
792 buf = dma_map_single(ctodev(card), skb->data, skb->len, DMA_TO_DEVICE); in gelic_descr_prepare_tx()
797 skb->data, skb->len); in gelic_descr_prepare_tx()
798 return -ENOMEM; in gelic_descr_prepare_tx()
801 descr->hw_regs.payload.dev_addr = cpu_to_be32(buf); in gelic_descr_prepare_tx()
802 descr->hw_regs.payload.size = cpu_to_be32(skb->len); in gelic_descr_prepare_tx()
803 descr->skb = skb; in gelic_descr_prepare_tx()
804 descr->hw_regs.data_status = 0; in gelic_descr_prepare_tx()
805 descr->hw_regs.next_descr_addr = 0; /* terminate hw descr */ in gelic_descr_prepare_tx()
809 card->tx_chain.head = descr->next; in gelic_descr_prepare_tx()
814 * gelic_card_kick_txdma - enables TX DMA processing
824 if (card->tx_dma_progress) in gelic_card_kick_txdma()
828 card->tx_dma_progress = 1; in gelic_card_kick_txdma()
830 descr->link.cpu_addr, 0); in gelic_card_kick_txdma()
832 card->tx_dma_progress = 0; in gelic_card_kick_txdma()
841 * gelic_net_xmit - transmits a frame over the device
854 spin_lock_irqsave(&card->tx_lock, flags); in gelic_net_xmit()
864 spin_unlock_irqrestore(&card->tx_lock, flags); in gelic_net_xmit()
874 netdev->stats.tx_dropped++; in gelic_net_xmit()
876 spin_unlock_irqrestore(&card->tx_lock, flags); in gelic_net_xmit()
883 descr->prev->hw_regs.next_descr_addr = in gelic_net_xmit()
884 cpu_to_be32(descr->link.cpu_addr); in gelic_net_xmit()
895 netdev->stats.tx_dropped++; in gelic_net_xmit()
897 descr->hw_regs.data_status = cpu_to_be32(GELIC_DESCR_TX_TAIL); in gelic_net_xmit()
900 card->tx_chain.head = descr; in gelic_net_xmit()
902 descr->prev->hw_regs.next_descr_addr = 0; in gelic_net_xmit()
906 spin_unlock_irqrestore(&card->tx_lock, flags); in gelic_net_xmit()
911 * gelic_net_pass_skb_up - takes an skb from a descriptor and passes it on
916 * iommu-unmaps the skb, fills out skb structure and passes the data to the
924 struct sk_buff *skb = descr->skb; in gelic_net_pass_skb_up()
927 data_status = be32_to_cpu(descr->hw_regs.data_status); in gelic_net_pass_skb_up()
928 data_error = be32_to_cpu(descr->hw_regs.data_error); in gelic_net_pass_skb_up()
931 be32_to_cpu(descr->hw_regs.payload.dev_addr), in gelic_net_pass_skb_up()
932 be32_to_cpu(descr->hw_regs.payload.size), DMA_FROM_DEVICE); in gelic_net_pass_skb_up()
934 skb_put(skb, be32_to_cpu(descr->hw_regs.valid_size)? in gelic_net_pass_skb_up()
935 be32_to_cpu(descr->hw_regs.valid_size) : in gelic_net_pass_skb_up()
936 be32_to_cpu(descr->hw_regs.result_size)); in gelic_net_pass_skb_up()
937 if (!descr->hw_regs.valid_size) in gelic_net_pass_skb_up()
939 be32_to_cpu(descr->hw_regs.result_size), in gelic_net_pass_skb_up()
940 be32_to_cpu(descr->hw_regs.payload.size), in gelic_net_pass_skb_up()
941 be32_to_cpu(descr->hw_regs.dmac_cmd_status)); in gelic_net_pass_skb_up()
943 descr->skb = NULL; in gelic_net_pass_skb_up()
949 skb->protocol = eth_type_trans(skb, netdev); in gelic_net_pass_skb_up()
952 if (netdev->features & NETIF_F_RXCSUM) { in gelic_net_pass_skb_up()
955 skb->ip_summed = CHECKSUM_UNNECESSARY; in gelic_net_pass_skb_up()
962 netdev->stats.rx_packets++; in gelic_net_pass_skb_up()
963 netdev->stats.rx_bytes += skb->len; in gelic_net_pass_skb_up()
970 * gelic_card_decode_one_descr - processes an rx descriptor
975 * processes an rx descriptor by iommu-unmapping the data buffer and passing
981 struct gelic_descr_chain *chain = &card->rx_chain; in gelic_card_decode_one_descr()
982 struct gelic_descr *descr = chain->head; in gelic_card_decode_one_descr()
997 if (card->vlan_required) { in gelic_card_decode_one_descr()
1000 vid = *(u16 *)(descr->skb->data) & VLAN_VID_MASK; in gelic_card_decode_one_descr()
1002 if (card->vlan[i].rx == vid) { in gelic_card_decode_one_descr()
1003 netdev = card->netdev[i]; in gelic_card_decode_one_descr()
1012 netdev = card->netdev[GELIC_PORT_ETHERNET_0]; in gelic_card_decode_one_descr()
1019 netdev->stats.rx_dropped++; in gelic_card_decode_one_descr()
1052 be32_to_cpu(descr->hw_regs.dmac_cmd_status) & in gelic_card_decode_one_descr()
1059 descr->hw_regs.next_descr_addr = 0; in gelic_card_decode_one_descr()
1070 chain->tail = descr; in gelic_card_decode_one_descr()
1071 chain->head = descr->next; in gelic_card_decode_one_descr()
1076 descr->prev->hw_regs.next_descr_addr = in gelic_card_decode_one_descr()
1077 cpu_to_be32(descr->link.cpu_addr); in gelic_card_decode_one_descr()
1081 * thus re-enable it in gelic_card_decode_one_descr()
1091 * gelic_net_poll - NAPI poll function called by the stack to return packets
1118 * gelic_card_interrupt - event handler for gelic_net
1126 status = card->irq_status; in gelic_card_interrupt()
1131 status &= card->irq_mask; in gelic_card_interrupt()
1135 napi_schedule(&card->napi); in gelic_card_interrupt()
1139 spin_lock_irqsave(&card->tx_lock, flags); in gelic_card_interrupt()
1140 card->tx_dma_progress = 0; in gelic_card_interrupt()
1143 gelic_card_kick_txdma(card, card->tx_chain.tail); in gelic_card_interrupt()
1144 spin_unlock_irqrestore(&card->tx_lock, flags); in gelic_card_interrupt()
1154 gelic_wl_interrupt(card->netdev[GELIC_PORT_WIRELESS], status); in gelic_card_interrupt()
1162 * gelic_net_poll_controller - artificial interrupt for netconsole etc.
1172 gelic_card_interrupt(netdev->irq, netdev); in gelic_net_poll_controller()
1173 gelic_card_set_irq_mask(card, card->irq_mask); in gelic_net_poll_controller()
1178 * gelic_net_open - called upon ifconfig up
1190 dev_dbg(ctodev(card), " -> %s %p\n", __func__, netdev); in gelic_net_open()
1197 dev_dbg(ctodev(card), " <- %s\n", __func__); in gelic_net_open()
1204 strscpy(info->driver, DRV_NAME, sizeof(info->driver)); in gelic_net_get_drvinfo()
1205 strscpy(info->version, DRV_VERSION, sizeof(info->version)); in gelic_net_get_drvinfo()
1216 if (card->ether_port_status & GELIC_LV1_ETHER_FULL_DUPLEX) in gelic_ether_get_link_ksettings()
1217 cmd->base.duplex = DUPLEX_FULL; in gelic_ether_get_link_ksettings()
1219 cmd->base.duplex = DUPLEX_HALF; in gelic_ether_get_link_ksettings()
1221 switch (card->ether_port_status & GELIC_LV1_ETHER_SPEED_MASK) { in gelic_ether_get_link_ksettings()
1223 cmd->base.speed = SPEED_10; in gelic_ether_get_link_ksettings()
1226 cmd->base.speed = SPEED_100; in gelic_ether_get_link_ksettings()
1229 cmd->base.speed = SPEED_1000; in gelic_ether_get_link_ksettings()
1233 cmd->base.speed = SPEED_10; in gelic_ether_get_link_ksettings()
1242 if (card->link_mode & GELIC_LV1_ETHER_AUTO_NEG) { in gelic_ether_get_link_ksettings()
1243 cmd->base.autoneg = AUTONEG_ENABLE; in gelic_ether_get_link_ksettings()
1245 cmd->base.autoneg = AUTONEG_DISABLE; in gelic_ether_get_link_ksettings()
1248 cmd->base.port = PORT_TP; in gelic_ether_get_link_ksettings()
1250 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported, in gelic_ether_get_link_ksettings()
1252 ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.advertising, in gelic_ether_get_link_ksettings()
1266 if (cmd->base.autoneg == AUTONEG_ENABLE) { in gelic_ether_set_link_ksettings()
1269 switch (cmd->base.speed) { in gelic_ether_set_link_ksettings()
1280 return -EINVAL; in gelic_ether_set_link_ksettings()
1282 if (cmd->base.duplex == DUPLEX_FULL) { in gelic_ether_set_link_ksettings()
1284 } else if (cmd->base.speed == SPEED_1000) { in gelic_ether_set_link_ksettings()
1286 return -EINVAL; in gelic_ether_set_link_ksettings()
1302 wol->supported = WAKE_MAGIC; in gelic_net_get_wol()
1304 wol->supported = 0; in gelic_net_get_wol()
1306 wol->wolopts = ps3_sys_manager_get_wol() ? wol->supported : 0; in gelic_net_get_wol()
1307 memset(&wol->sopass, 0, sizeof(wol->sopass)); in gelic_net_get_wol()
1314 u64 v1, v2; in gelic_net_set_wol() local
1318 return -EPERM; in gelic_net_set_wol()
1320 if (wol->wolopts & ~WAKE_MAGIC) in gelic_net_set_wol()
1321 return -EINVAL; in gelic_net_set_wol()
1324 if (wol->wolopts & WAKE_MAGIC) { in gelic_net_set_wol()
1329 &v1, &v2); in gelic_net_set_wol()
1333 status = -EIO; in gelic_net_set_wol()
1340 &v1, &v2); in gelic_net_set_wol()
1346 status = -EIO; in gelic_net_set_wol()
1353 &v1, &v2); in gelic_net_set_wol()
1357 status = -EIO; in gelic_net_set_wol()
1364 &v1, &v2); in gelic_net_set_wol()
1370 status = -EIO; in gelic_net_set_wol()
1387 * gelic_net_tx_timeout_task - task scheduled by the watchdog timeout
1397 struct net_device *netdev = card->netdev[GELIC_PORT_ETHERNET_0]; in gelic_net_tx_timeout_task()
1401 if (!(netdev->flags & IFF_UP)) in gelic_net_tx_timeout_task()
1411 atomic_dec(&card->tx_timeout_task_counter); in gelic_net_tx_timeout_task()
1415 * gelic_net_tx_timeout - called when the tx timeout watchdog kicks in.
1426 atomic_inc(&card->tx_timeout_task_counter); in gelic_net_tx_timeout()
1427 if (netdev->flags & IFF_UP) in gelic_net_tx_timeout()
1428 schedule_work(&card->tx_timeout_task); in gelic_net_tx_timeout()
1430 atomic_dec(&card->tx_timeout_task_counter); in gelic_net_tx_timeout()
1447 * gelic_ether_setup_netdev_ops - initialization of net_device operations
1456 netdev->watchdog_timeo = GELIC_NET_WATCHDOG_TIMEOUT; in gelic_ether_setup_netdev_ops()
1459 netdev->ethtool_ops = &gelic_ether_ethtool_ops; in gelic_ether_setup_netdev_ops()
1460 netdev->netdev_ops = &gelic_netdevice_ops; in gelic_ether_setup_netdev_ops()
1464 * gelic_net_setup_netdev - initialization of net_device
1476 u64 v1, v2; in gelic_net_setup_netdev() local
1478 netdev->hw_features = NETIF_F_IP_CSUM | NETIF_F_RXCSUM; in gelic_net_setup_netdev()
1480 netdev->features = NETIF_F_IP_CSUM; in gelic_net_setup_netdev()
1482 netdev->features |= NETIF_F_RXCSUM; in gelic_net_setup_netdev()
1486 0, 0, 0, &v1, &v2); in gelic_net_setup_netdev()
1487 v1 <<= 16; in gelic_net_setup_netdev()
1488 if (status || !is_valid_ether_addr((u8 *)&v1)) { in gelic_net_setup_netdev()
1492 return -EINVAL; in gelic_net_setup_netdev()
1494 eth_hw_addr_set(netdev, (u8 *)&v1); in gelic_net_setup_netdev()
1496 if (card->vlan_required) { in gelic_net_setup_netdev()
1497 netdev->hard_header_len += VLAN_HLEN; in gelic_net_setup_netdev()
1502 netdev->features |= NETIF_F_VLAN_CHALLENGED; in gelic_net_setup_netdev()
1505 /* MTU range: 64 - 1518 */ in gelic_net_setup_netdev()
1506 netdev->min_mtu = GELIC_NET_MIN_MTU; in gelic_net_setup_netdev()
1507 netdev->max_mtu = GELIC_NET_MAX_MTU; in gelic_net_setup_netdev()
1512 __func__, netdev->name, status); in gelic_net_setup_netdev()
1516 netdev->name, netdev->dev_addr); in gelic_net_setup_netdev()
1524 * gelic_alloc_card_net - allocates net_device and card structure
1547 GELIC_ALIGN - 1; in gelic_alloc_card_net()
1553 card->unalign = p; in gelic_alloc_card_net()
1560 kfree(card->unalign); in gelic_alloc_card_net()
1566 port->netdev = *netdev; in gelic_alloc_card_net()
1567 port->card = card; in gelic_alloc_card_net()
1568 port->type = GELIC_PORT_ETHERNET_0; in gelic_alloc_card_net()
1571 card->netdev[GELIC_PORT_ETHERNET_0] = *netdev; in gelic_alloc_card_net()
1573 INIT_WORK(&card->tx_timeout_task, gelic_net_tx_timeout_task); in gelic_alloc_card_net()
1574 init_waitqueue_head(&card->waitq); in gelic_alloc_card_net()
1575 atomic_set(&card->tx_timeout_task_counter, 0); in gelic_alloc_card_net()
1576 mutex_init(&card->updown_lock); in gelic_alloc_card_net()
1577 atomic_set(&card->users, 0); in gelic_alloc_card_net()
1584 u64 v1, v2; in gelic_card_get_vlan_info() local
1606 0, 0, &v1, &v2); in gelic_card_get_vlan_info()
1607 if (status || !v1) { in gelic_card_get_vlan_info()
1612 card->vlan[i].tx = 0; in gelic_card_get_vlan_info()
1613 card->vlan[i].rx = 0; in gelic_card_get_vlan_info()
1616 card->vlan[i].tx = (u16)v1; in gelic_card_get_vlan_info()
1622 0, 0, &v1, &v2); in gelic_card_get_vlan_info()
1623 if (status || !v1) { in gelic_card_get_vlan_info()
1628 card->vlan[i].tx = 0; in gelic_card_get_vlan_info()
1629 card->vlan[i].rx = 0; in gelic_card_get_vlan_info()
1632 card->vlan[i].rx = (u16)v1; in gelic_card_get_vlan_info()
1635 i, card->vlan[i].tx, card->vlan[i].rx); in gelic_card_get_vlan_info()
1638 if (card->vlan[GELIC_PORT_ETHERNET_0].tx) { in gelic_card_get_vlan_info()
1639 BUG_ON(!card->vlan[GELIC_PORT_WIRELESS].tx); in gelic_card_get_vlan_info()
1640 card->vlan_required = 1; in gelic_card_get_vlan_info()
1642 card->vlan_required = 0; in gelic_card_get_vlan_info()
1646 card->vlan[GELIC_PORT_WIRELESS].tx = 0; in gelic_card_get_vlan_info()
1647 card->vlan[GELIC_PORT_WIRELESS].rx = 0; in gelic_card_get_vlan_info()
1651 card->vlan_required? "enabled" : "disabled"); in gelic_card_get_vlan_info()
1654 * ps3_gelic_driver_probe - add a device to the control of this driver
1669 dev_dbg(&dev->core, "%s:ps3_open_hv_device failed\n", in ps3_gelic_driver_probe()
1674 result = ps3_dma_region_create(dev->d_region); in ps3_gelic_driver_probe()
1677 dev_dbg(&dev->core, "%s:ps3_dma_region_create failed(%d)\n", in ps3_gelic_driver_probe()
1686 dev_info(&dev->core, "%s:gelic_net_alloc_card failed\n", in ps3_gelic_driver_probe()
1688 result = -ENOMEM; in ps3_gelic_driver_probe()
1692 card->dev = dev; in ps3_gelic_driver_probe()
1697 card->link_mode = GELIC_LV1_ETHER_AUTO_NEG; in ps3_gelic_driver_probe()
1702 ps3_mm_phys_to_lpar(__pa(&card->irq_status)), in ps3_gelic_driver_probe()
1706 dev_dbg(&dev->core, in ps3_gelic_driver_probe()
1709 result = -EIO; in ps3_gelic_driver_probe()
1714 &card->irq); in ps3_gelic_driver_probe()
1720 result = -EPERM; in ps3_gelic_driver_probe()
1723 result = request_irq(card->irq, gelic_card_interrupt, in ps3_gelic_driver_probe()
1724 0, netdev->name, card); in ps3_gelic_driver_probe()
1733 card->irq_mask = GELIC_CARD_RXINT | GELIC_CARD_TXINT | in ps3_gelic_driver_probe()
1737 result = gelic_card_init_chain(card, &card->tx_chain, in ps3_gelic_driver_probe()
1738 card->descr, GELIC_NET_TX_DESCRIPTORS); in ps3_gelic_driver_probe()
1741 result = gelic_card_init_chain(card, &card->rx_chain, in ps3_gelic_driver_probe()
1742 card->descr + GELIC_NET_TX_DESCRIPTORS, in ps3_gelic_driver_probe()
1748 card->tx_top = card->tx_chain.head; in ps3_gelic_driver_probe()
1749 card->rx_top = card->rx_chain.head; in ps3_gelic_driver_probe()
1751 card->rx_top, card->tx_top, sizeof(struct gelic_descr), in ps3_gelic_driver_probe()
1758 spin_lock_init(&card->tx_lock); in ps3_gelic_driver_probe()
1759 card->tx_dma_progress = 0; in ps3_gelic_driver_probe()
1762 netdev->irq = card->irq; in ps3_gelic_driver_probe()
1763 SET_NETDEV_DEV(netdev, &card->dev->core); in ps3_gelic_driver_probe()
1764 gelic_ether_setup_netdev_ops(netdev, &card->napi); in ps3_gelic_driver_probe()
1767 dev_dbg(&dev->core, "%s: setup_netdev failed %d\n", in ps3_gelic_driver_probe()
1775 dev_dbg(&dev->core, "%s: WL init failed\n", __func__); in ps3_gelic_driver_probe()
1784 gelic_card_free_chain(card, card->rx_chain.head); in ps3_gelic_driver_probe()
1786 gelic_card_free_chain(card, card->tx_chain.head); in ps3_gelic_driver_probe()
1788 free_irq(card->irq, card); in ps3_gelic_driver_probe()
1789 netdev->irq = 0; in ps3_gelic_driver_probe()
1791 ps3_sb_event_receive_port_destroy(dev, card->irq); in ps3_gelic_driver_probe()
1798 kfree(netdev_card(netdev)->unalign); in ps3_gelic_driver_probe()
1801 ps3_dma_region_free(dev->d_region); in ps3_gelic_driver_probe()
1809 * ps3_gelic_driver_remove - remove a device from the control of this driver
1818 /* set auto-negotiation */ in ps3_gelic_driver_remove()
1835 gelic_card_free_chain(card, card->tx_top); in ps3_gelic_driver_remove()
1836 gelic_card_free_chain(card, card->rx_top); in ps3_gelic_driver_remove()
1838 netdev0 = card->netdev[GELIC_PORT_ETHERNET_0]; in ps3_gelic_driver_remove()
1840 free_irq(card->irq, card); in ps3_gelic_driver_remove()
1841 netdev0->irq = 0; in ps3_gelic_driver_remove()
1842 ps3_sb_event_receive_port_destroy(card->dev, card->irq); in ps3_gelic_driver_remove()
1844 wait_event(card->waitq, in ps3_gelic_driver_remove()
1845 atomic_read(&card->tx_timeout_task_counter) == 0); in ps3_gelic_driver_remove()
1851 kfree(netdev_card(netdev0)->unalign); in ps3_gelic_driver_remove()
1856 ps3_dma_region_free(dev->d_region); in ps3_gelic_driver_remove()
1876 : -ENODEV; in ps3_gelic_driver_init()