p@2550: /**
p@2550: Network Driver for Beckhoff CCAT communication controller
p@2550: Copyright (C) 2014 Beckhoff Automation GmbH
p@2550: Author: Patrick Bruenn
p@2550:
p@2550: This program is free software; you can redistribute it and/or modify
p@2550: it under the terms of the GNU General Public License as published by
p@2550: the Free Software Foundation; either version 2 of the License, or
p@2550: (at your option) any later version.
p@2550:
p@2550: This program is distributed in the hope that it will be useful,
p@2550: but WITHOUT ANY WARRANTY; without even the implied warranty of
p@2550: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
p@2550: GNU General Public License for more details.
p@2550:
p@2550: You should have received a copy of the GNU General Public License along
p@2550: with this program; if not, write to the Free Software Foundation, Inc.,
p@2550: 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
p@2550: */
p@2550:
p@2550: #include
p@2550: #include
p@2550: #include
p@2550: #include
p@2550:
p@2550: #include "module.h"
p@2550: #include "netdev.h"
p@2550:
p@2550: /**
p@2550: * EtherCAT frame to enable forwarding on EtherCAT Terminals
p@2550: */
p@2567: static const u8 frameForwardEthernetFrames[] = {
p@2550: 0x01, 0x01, 0x05, 0x01, 0x00, 0x00,
p@2550: 0x00, 0x1b, 0x21, 0x36, 0x1b, 0xce,
p@2550: 0x88, 0xa4, 0x0e, 0x10,
p@2550: 0x08,
p@2550: 0x00,
p@2550: 0x00, 0x00,
p@2550: 0x00, 0x01,
p@2550: 0x02, 0x00,
p@2550: 0x00, 0x00,
p@2550: 0x00, 0x00,
p@2550: 0x00, 0x00
p@2550: };
p@2550:
p@2550: #define FIFO_LENGTH 64
p@2576: #define POLL_TIME ktime_set(0, 100 * NSEC_PER_USEC)
p@2576:
p@2576: /**
p@2576: * Helper to check if frame in tx dma memory was already marked as sent by CCAT
p@2576: */
p@2576: static inline bool ccat_eth_frame_sent(const struct ccat_eth_frame *const frame)
p@2576: {
p@2576: return le32_to_cpu(frame->tx_flags) & CCAT_FRAME_SENT;
p@2576: }
p@2576:
p@2576: /**
p@2576: * Helper to check if frame in tx dma memory was already marked as sent by CCAT
p@2576: */
p@2576: static inline bool ccat_eth_frame_received(const struct ccat_eth_frame *const
p@2576: frame)
p@2576: {
p@2576: return le32_to_cpu(frame->rx_flags) & CCAT_FRAME_RECEIVED;
p@2576: }
p@2550:
p@2550: static void ecdev_kfree_skb_any(struct sk_buff *skb)
p@2550: {
p@2550: /* never release a skb in EtherCAT mode */
p@2550: }
p@2550:
p@2570: static bool ecdev_carrier_ok(const struct net_device *const netdev)
p@2567: {
p@2567: struct ccat_eth_priv *const priv = netdev_priv(netdev);
p@2567: return ecdev_get_link(priv->ecdev);
p@2567: }
p@2567:
p@2550: static void ecdev_carrier_on(struct net_device *const netdev)
p@2550: {
p@2550: struct ccat_eth_priv *const priv = netdev_priv(netdev);
p@2550: ecdev_set_link(priv->ecdev, 1);
p@2550: }
p@2550:
p@2550: static void ecdev_carrier_off(struct net_device *const netdev)
p@2550: {
p@2550: struct ccat_eth_priv *const priv = netdev_priv(netdev);
p@2550: ecdev_set_link(priv->ecdev, 0);
p@2550: }
p@2550:
p@2550: static void ecdev_nop(struct net_device *const netdev)
p@2550: {
p@2550: /* dummy called if nothing has to be done in EtherCAT operation mode */
p@2550: }
p@2550:
p@2550: static void unregister_ecdev(struct net_device *const netdev)
p@2550: {
p@2550: struct ccat_eth_priv *const priv = netdev_priv(netdev);
p@2550: ecdev_close(priv->ecdev);
p@2550: ecdev_withdraw(priv->ecdev);
p@2550: }
p@2550:
p@2576: static void ccat_eth_fifo_inc(struct ccat_eth_dma_fifo *fifo)
p@2576: {
p@2576: if (++fifo->next >= fifo->end)
p@2576: fifo->next = fifo->dma.virt;
p@2576: }
p@2576:
p@2576: typedef void (*fifo_add_function) (struct ccat_eth_dma_fifo *,
p@2576: struct ccat_eth_frame *);
p@2576:
p@2576: static void ccat_eth_rx_fifo_add(struct ccat_eth_dma_fifo *fifo,
p@2576: struct ccat_eth_frame *frame)
p@2550: {
p@2550: const size_t offset = ((void *)(frame) - fifo->dma.virt);
p@2567: const u32 addr_and_length = (1 << 31) | offset;
p@2567:
p@2576: frame->rx_flags = cpu_to_le32(0);
p@2550: iowrite32(addr_and_length, fifo->reg);
p@2550: }
p@2550:
p@2576: static void ccat_eth_tx_fifo_add_free(struct ccat_eth_dma_fifo *fifo,
p@2576: struct ccat_eth_frame *frame)
p@2550: {
p@2550: /* mark frame as ready to use for tx */
p@2576: frame->tx_flags = cpu_to_le32(CCAT_FRAME_SENT);
p@2550: }
p@2550:
p@2550: static void ccat_eth_dma_fifo_reset(struct ccat_eth_dma_fifo *fifo)
p@2550: {
p@2550: /* reset hw fifo */
p@2550: iowrite32(0, fifo->reg + 0x8);
p@2550: wmb();
p@2550:
p@2550: if (fifo->add) {
p@2576: fifo->next = fifo->dma.virt;
p@2576: do {
p@2576: fifo->add(fifo, fifo->next);
p@2576: ccat_eth_fifo_inc(fifo);
p@2576: } while (fifo->next != fifo->dma.virt);
p@2550: }
p@2550: }
p@2550:
p@2550: static int ccat_eth_dma_fifo_init(struct ccat_eth_dma_fifo *fifo,
p@2550: void __iomem * const fifo_reg,
p@2550: fifo_add_function add, size_t channel,
p@2550: struct ccat_eth_priv *const priv)
p@2550: {
p@2550: if (0 !=
p@2550: ccat_dma_init(&fifo->dma, channel, priv->ccatdev->bar[2].ioaddr,
p@2550: &priv->ccatdev->pdev->dev)) {
p@2567: pr_info("init DMA%llu memory failed.\n", (u64) channel);
p@2550: return -1;
p@2550: }
p@2550: fifo->add = add;
p@2576: fifo->end = ((struct ccat_eth_frame *)fifo->dma.virt) + FIFO_LENGTH;
p@2550: fifo->reg = fifo_reg;
p@2550: return 0;
p@2550: }
p@2550:
p@2550: /**
p@2550: * Stop both (Rx/Tx) DMA fifo's and free related management structures
p@2550: */
p@2550: static void ccat_eth_priv_free_dma(struct ccat_eth_priv *priv)
p@2550: {
p@2550: /* reset hw fifo's */
p@2550: iowrite32(0, priv->rx_fifo.reg + 0x8);
p@2550: iowrite32(0, priv->tx_fifo.reg + 0x8);
p@2550: wmb();
p@2550:
p@2550: /* release dma */
p@2550: ccat_dma_free(&priv->rx_fifo.dma);
p@2550: ccat_dma_free(&priv->tx_fifo.dma);
p@2550: }
p@2550:
p@2550: /**
p@2550: * Initalizes both (Rx/Tx) DMA fifo's and related management structures
p@2550: */
p@2550: static int ccat_eth_priv_init_dma(struct ccat_eth_priv *priv)
p@2550: {
p@2550: if (ccat_eth_dma_fifo_init
p@2550: (&priv->rx_fifo, priv->reg.rx_fifo, ccat_eth_rx_fifo_add,
p@2569: priv->info.rx_dma_chan, priv)) {
p@2550: pr_warn("init Rx DMA fifo failed.\n");
p@2550: return -1;
p@2550: }
p@2550:
p@2550: if (ccat_eth_dma_fifo_init
p@2550: (&priv->tx_fifo, priv->reg.tx_fifo, ccat_eth_tx_fifo_add_free,
p@2569: priv->info.tx_dma_chan, priv)) {
p@2550: pr_warn("init Tx DMA fifo failed.\n");
p@2550: ccat_dma_free(&priv->rx_fifo.dma);
p@2550: return -1;
p@2550: }
p@2550:
p@2550: /* disable MAC filter */
p@2550: iowrite8(0, priv->reg.mii + 0x8 + 6);
p@2550: wmb();
p@2550: return 0;
p@2550: }
p@2550:
p@2550: /**
p@2550: * Initializes the CCat... members of the ccat_eth_priv structure.
p@2550: * Call this function only if info and ioaddr are already initialized!
p@2550: */
p@2550: static void ccat_eth_priv_init_mappings(struct ccat_eth_priv *priv)
p@2550: {
p@2569: struct ccat_mac_infoblock offsets;
p@2550: void __iomem *const func_base =
p@2569: priv->ccatdev->bar[0].ioaddr + priv->info.addr;
p@2567:
p@2550: memcpy_fromio(&offsets, func_base, sizeof(offsets));
p@2569: priv->reg.mii = func_base + offsets.mii;
p@2569: priv->reg.tx_fifo = func_base + offsets.tx_fifo;
p@2569: priv->reg.rx_fifo = func_base + offsets.tx_fifo + 0x10;
p@2569: priv->reg.mac = func_base + offsets.mac;
p@2569: priv->reg.rx_mem = func_base + offsets.rx_mem;
p@2569: priv->reg.tx_mem = func_base + offsets.tx_mem;
p@2569: priv->reg.misc = func_base + offsets.misc;
p@2550: }
p@2550:
p@2572: static netdev_tx_t ccat_eth_start_xmit(struct sk_buff *skb,
p@2572: struct net_device *dev)
p@2572: {
p@2576: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2576: struct ccat_eth_dma_fifo *const fifo = &priv->tx_fifo;
p@2572: u32 addr_and_length;
p@2572:
p@2572: if (skb_is_nonlinear(skb)) {
p@2572: pr_warn("Non linear skb not supported -> drop frame.\n");
p@2572: atomic64_inc(&priv->tx_dropped);
p@2572: priv->kfree_skb_any(skb);
p@2572: return NETDEV_TX_OK;
p@2572: }
p@2572:
p@2576: if (skb->len > sizeof(fifo->next->data)) {
p@2572: pr_warn("skb.len %llu exceeds dma buffer %llu -> drop frame.\n",
p@2576: (u64) skb->len, (u64) sizeof(fifo->next->data));
p@2572: atomic64_inc(&priv->tx_dropped);
p@2572: priv->kfree_skb_any(skb);
p@2572: return NETDEV_TX_OK;
p@2572: }
p@2572:
p@2576: if (!ccat_eth_frame_sent(fifo->next)) {
p@2572: netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
p@2576: priv->stop_queue(priv->netdev);
p@2572: return NETDEV_TX_BUSY;
p@2572: }
p@2572:
p@2572: /* prepare frame in DMA memory */
p@2576: fifo->next->tx_flags = cpu_to_le32(0);
p@2576: fifo->next->length = cpu_to_le16(skb->len);
p@2576: memcpy(fifo->next->data, skb->data, skb->len);
p@2576:
p@2576: /* Queue frame into CCAT TX-FIFO, CCAT ignores the first 8 bytes of the tx descriptor */
p@2576: addr_and_length = offsetof(struct ccat_eth_frame, length);
p@2578: addr_and_length += ((void *)fifo->next - fifo->dma.virt);
p@2576: addr_and_length += ((skb->len + CCAT_ETH_FRAME_HEAD_LEN) / 8) << 24;
p@2576: iowrite32(addr_and_length, priv->reg.tx_fifo);
p@2576:
p@2576: /* update stats */
p@2576: atomic64_add(skb->len, &priv->tx_bytes);
p@2572:
p@2572: priv->kfree_skb_any(skb);
p@2572:
p@2576: ccat_eth_fifo_inc(fifo);
p@2572: /* stop queue if tx ring is full */
p@2576: if (!ccat_eth_frame_sent(fifo->next)) {
p@2576: priv->stop_queue(priv->netdev);
p@2572: }
p@2572: return NETDEV_TX_OK;
p@2572: }
p@2572:
p@2572: /**
p@2572: * Function to transmit a raw buffer to the network (f.e. frameForwardEthernetFrames)
p@2572: * @dev a valid net_device
p@2572: * @data pointer to your raw buffer
p@2572: * @len number of bytes in the raw buffer to transmit
p@2572: */
p@2572: static void ccat_eth_xmit_raw(struct net_device *dev, const char *const data,
p@2572: size_t len)
p@2572: {
p@2572: struct sk_buff *skb = dev_alloc_skb(len);
p@2572:
p@2572: skb->dev = dev;
p@2572: skb_copy_to_linear_data(skb, data, len);
p@2572: skb_put(skb, len);
p@2572: ccat_eth_start_xmit(skb, dev);
p@2572: }
p@2572:
p@2572: static void ccat_eth_receive(struct net_device *const dev,
p@2576: const void *const data, const size_t len)
p@2576: {
p@2576: struct sk_buff *const skb = dev_alloc_skb(len + NET_IP_ALIGN);
p@2576: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2572:
p@2572: if (!skb) {
p@2572: pr_info("%s() out of memory :-(\n", __FUNCTION__);
p@2572: atomic64_inc(&priv->rx_dropped);
p@2572: return;
p@2572: }
p@2572: skb->dev = dev;
p@2572: skb_reserve(skb, NET_IP_ALIGN);
p@2576: skb_copy_to_linear_data(skb, data, len);
p@2572: skb_put(skb, len);
p@2572: skb->protocol = eth_type_trans(skb, dev);
p@2572: skb->ip_summed = CHECKSUM_UNNECESSARY;
p@2572: atomic64_add(len, &priv->rx_bytes);
p@2572: netif_rx(skb);
p@2572: }
p@2572:
p@2576: static void ccat_eth_link_down(struct net_device *const dev)
p@2572: {
p@2572: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2572:
p@2572: priv->stop_queue(dev);
p@2572: priv->carrier_off(dev);
p@2572: netdev_info(dev, "NIC Link is Down\n");
p@2572: }
p@2572:
p@2572: static void ccat_eth_link_up(struct net_device *const dev)
p@2572: {
p@2572: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2572:
p@2572: netdev_info(dev, "NIC Link is Up\n");
p@2572: /* TODO netdev_info(dev, "NIC Link is Up %u Mbps %s Duplex\n",
p@2572: speed == SPEED_100 ? 100 : 10,
p@2572: cmd.duplex == DUPLEX_FULL ? "Full" : "Half"); */
p@2572:
p@2572: ccat_eth_dma_fifo_reset(&priv->rx_fifo);
p@2572: ccat_eth_dma_fifo_reset(&priv->tx_fifo);
p@2572:
p@2572: /* TODO reset CCAT MAC register */
p@2572:
p@2572: ccat_eth_xmit_raw(dev, frameForwardEthernetFrames,
p@2572: sizeof(frameForwardEthernetFrames));
p@2572: priv->carrier_on(dev);
p@2572: priv->start_queue(dev);
p@2572: }
p@2572:
p@2550: /**
p@2550: * Read link state from CCAT hardware
p@2550: * @return 1 if link is up, 0 if not
p@2550: */
p@2550: inline static size_t ccat_eth_priv_read_link_state(const struct ccat_eth_priv
p@2550: *const priv)
p@2550: {
p@2550: return (1 << 24) == (ioread32(priv->reg.mii + 0x8 + 4) & (1 << 24));
p@2550: }
p@2550:
p@2572: /**
p@2572: * Poll for link state changes
p@2572: */
p@2572: static void poll_link(struct ccat_eth_priv *const priv)
p@2572: {
p@2572: const size_t link = ccat_eth_priv_read_link_state(priv);
p@2572:
p@2572: if (link != priv->carrier_ok(priv->netdev)) {
p@2572: if (link)
p@2572: ccat_eth_link_up(priv->netdev);
p@2572: else
p@2572: ccat_eth_link_down(priv->netdev);
p@2572: }
p@2572: }
p@2572:
p@2572: /**
p@2576: * Poll for available rx dma descriptors in ethernet operating mode
p@2576: */
p@2576: static void poll_rx(struct ccat_eth_priv *const priv)
p@2576: {
p@2576: static const size_t overhead = CCAT_ETH_FRAME_HEAD_LEN - 4;
p@2576: struct ccat_eth_dma_fifo *const fifo = &priv->rx_fifo;
p@2576:
p@2576: /* TODO omit possible deadlock in situations with heavy traffic */
p@2576: while (ccat_eth_frame_received(fifo->next)) {
p@2576: const size_t len = le16_to_cpu(fifo->next->length) - overhead;
p@2576: if (priv->ecdev) {
p@2576: ecdev_receive(priv->ecdev, fifo->next->data, len);
p@2576: } else {
p@2576: ccat_eth_receive(priv->netdev, fifo->next->data, len);
p@2576: }
p@2576: ccat_eth_rx_fifo_add(fifo, fifo->next);
p@2576: ccat_eth_fifo_inc(fifo);
p@2576: }
p@2576: }
p@2576:
p@2572: static void ec_poll_rx(struct net_device *dev)
p@2572: {
p@2576: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2576: poll_rx(priv);
p@2572: }
p@2572:
p@2572: /**
p@2572: * Poll for available tx dma descriptors in ethernet operating mode
p@2572: */
p@2572: static void poll_tx(struct ccat_eth_priv *const priv)
p@2572: {
p@2576: if (ccat_eth_frame_sent(priv->tx_fifo.next)) {
p@2572: netif_wake_queue(priv->netdev);
p@2572: }
p@2572: }
p@2572:
p@2572: /**
p@2572: * Since CCAT doesn't support interrupts until now, we have to poll
p@2572: * some status bits to recognize things like link change etc.
p@2572: */
p@2572: static enum hrtimer_restart poll_timer_callback(struct hrtimer *timer)
p@2572: {
p@2576: struct ccat_eth_priv *const priv =
p@2576: container_of(timer, struct ccat_eth_priv, poll_timer);
p@2572:
p@2572: poll_link(priv);
p@2576: if(!priv->ecdev) {
p@2572: poll_rx(priv);
p@2576: poll_tx(priv);
p@2576: }
p@2576: hrtimer_forward_now(timer, POLL_TIME);
p@2572: return HRTIMER_RESTART;
p@2572: }
p@2572:
p@2550: static struct rtnl_link_stats64 *ccat_eth_get_stats64(struct net_device *dev, struct rtnl_link_stats64
p@2550: *storage)
p@2550: {
p@2550: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2569: struct ccat_mac_register mac;
p@2550: memcpy_fromio(&mac, priv->reg.mac, sizeof(mac));
p@2569: storage->rx_packets = mac.rx_frames; /* total packets received */
p@2569: storage->tx_packets = mac.tx_frames; /* total packets transmitted */
p@2550: storage->rx_bytes = atomic64_read(&priv->rx_bytes); /* total bytes received */
p@2550: storage->tx_bytes = atomic64_read(&priv->tx_bytes); /* total bytes transmitted */
p@2569: storage->rx_errors = mac.frame_len_err + mac.rx_mem_full + mac.crc_err + mac.rx_err; /* bad packets received */
p@2573: storage->tx_errors = mac.tx_mem_full; /* packet transmit problems */
p@2550: storage->rx_dropped = atomic64_read(&priv->rx_dropped); /* no space in linux buffers */
p@2550: storage->tx_dropped = atomic64_read(&priv->tx_dropped); /* no space available in linux */
p@2550: //TODO __u64 multicast; /* multicast packets received */
p@2550: //TODO __u64 collisions;
p@2550:
p@2550: /* detailed rx_errors: */
p@2569: storage->rx_length_errors = mac.frame_len_err;
p@2569: storage->rx_over_errors = mac.rx_mem_full; /* receiver ring buff overflow */
p@2569: storage->rx_crc_errors = mac.crc_err; /* recved pkt with crc error */
p@2569: storage->rx_frame_errors = mac.rx_err; /* recv'd frame alignment error */
p@2569: storage->rx_fifo_errors = mac.rx_mem_full; /* recv'r fifo overrun */
p@2550: //TODO __u64 rx_missed_errors; /* receiver missed packet */
p@2550:
p@2550: /* detailed tx_errors */
p@2550: //TODO __u64 tx_aborted_errors;
p@2550: //TODO __u64 tx_carrier_errors;
p@2550: //TODO __u64 tx_fifo_errors;
p@2550: //TODO __u64 tx_heartbeat_errors;
p@2550: //TODO __u64 tx_window_errors;
p@2550:
p@2550: /* for cslip etc */
p@2550: //TODO __u64 rx_compressed;
p@2550: //TODO __u64 tx_compressed;
p@2550: return storage;
p@2550: }
p@2550:
p@2572: static int ccat_eth_open(struct net_device *dev)
p@2572: {
p@2572: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2572:
p@2572: hrtimer_init(&priv->poll_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
p@2572: priv->poll_timer.function = poll_timer_callback;
p@2576: hrtimer_start(&priv->poll_timer, POLL_TIME, HRTIMER_MODE_REL);
p@2572: return 0;
p@2572: }
p@2572:
p@2572: static int ccat_eth_stop(struct net_device *dev)
p@2572: {
p@2572: struct ccat_eth_priv *const priv = netdev_priv(dev);
p@2572:
p@2572: priv->stop_queue(dev);
p@2572: hrtimer_cancel(&priv->poll_timer);
p@2572: return 0;
p@2572: }
p@2572:
p@2572: static const struct net_device_ops ccat_eth_netdev_ops = {
p@2572: .ndo_get_stats64 = ccat_eth_get_stats64,
p@2572: .ndo_open = ccat_eth_open,
p@2572: .ndo_start_xmit = ccat_eth_start_xmit,
p@2572: .ndo_stop = ccat_eth_stop,
p@2572: };
p@2572:
p@2550: struct ccat_eth_priv *ccat_eth_init(const struct ccat_device *const ccatdev,
p@2550: const void __iomem * const addr)
p@2550: {
p@2550: struct ccat_eth_priv *priv;
p@2550: struct net_device *const netdev = alloc_etherdev(sizeof(*priv));
p@2567:
p@2550: priv = netdev_priv(netdev);
p@2550: priv->netdev = netdev;
p@2550: priv->ccatdev = ccatdev;
p@2550:
p@2550: /* ccat register mappings */
p@2550: memcpy_fromio(&priv->info, addr, sizeof(priv->info));
p@2550: ccat_eth_priv_init_mappings(priv);
p@2550:
p@2550: if (ccat_eth_priv_init_dma(priv)) {
p@2550: pr_warn("%s(): DMA initialization failed.\n", __FUNCTION__);
p@2550: free_netdev(netdev);
p@2550: return NULL;
p@2550: }
p@2550:
p@2550: /* init netdev with MAC and stack callbacks */
p@2569: memcpy_fromio(netdev->dev_addr, priv->reg.mii + 8, netdev->addr_len);
p@2550: netdev->netdev_ops = &ccat_eth_netdev_ops;
p@2550:
p@2550: /* use as EtherCAT device? */
p@2572: priv->ecdev = ecdev_offer(netdev, ec_poll_rx, THIS_MODULE);
p@2550: if (priv->ecdev) {
p@2550: priv->carrier_off = ecdev_carrier_off;
p@2567: priv->carrier_ok = ecdev_carrier_ok;
p@2550: priv->carrier_on = ecdev_carrier_on;
p@2550: priv->kfree_skb_any = ecdev_kfree_skb_any;
p@2550: priv->start_queue = ecdev_nop;
p@2550: priv->stop_queue = ecdev_nop;
p@2550: priv->unregister = unregister_ecdev;
p@2568:
p@2568: priv->carrier_off(netdev);
p@2550: if (ecdev_open(priv->ecdev)) {
p@2550: pr_info("unable to register network device.\n");
p@2550: ecdev_withdraw(priv->ecdev);
p@2550: ccat_eth_priv_free_dma(priv);
p@2550: free_netdev(netdev);
p@2550: return NULL;
p@2550: }
p@2550: return priv;
p@2550: }
p@2550:
p@2550: /* EtherCAT disabled -> prepare normal ethernet mode */
p@2550: priv->carrier_off = netif_carrier_off;
p@2567: priv->carrier_ok = netif_carrier_ok;
p@2550: priv->carrier_on = netif_carrier_on;
p@2550: priv->kfree_skb_any = dev_kfree_skb_any;
p@2550: priv->start_queue = netif_start_queue;
p@2550: priv->stop_queue = netif_stop_queue;
p@2550: priv->unregister = unregister_netdev;
p@2568:
p@2568: priv->carrier_off(netdev);
p@2550: if (register_netdev(netdev)) {
p@2550: pr_info("unable to register network device.\n");
p@2550: ccat_eth_priv_free_dma(priv);
p@2550: free_netdev(netdev);
p@2550: return NULL;
p@2550: }
p@2550: pr_info("registered %s as network device.\n", netdev->name);
p@2550: return priv;
p@2550: }
p@2550:
p@2550: void ccat_eth_remove(struct ccat_eth_priv *const priv)
p@2550: {
p@2550: priv->unregister(priv->netdev);
p@2550: ccat_eth_priv_free_dma(priv);
p@2550: free_netdev(priv->netdev);
p@2576: }